From 6af83a7d055a1f1a8698423455c66f26afed26f5 Mon Sep 17 00:00:00 2001 From: chrismue Date: Tue, 7 Feb 2023 06:47:39 +0100 Subject: [PATCH] Sample adjusted for Python3 (#7819) Co-authored-by: chrismue Co-authored-by: Derek Bailey --- samples/sample_binary.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/sample_binary.py b/samples/sample_binary.py index cd250a9cf..09a239c2d 100644 --- a/samples/sample_binary.py +++ b/samples/sample_binary.py @@ -99,20 +99,20 @@ def main(): # Note: We did not set the `Mana` field explicitly, so we get a default value. assert monster.Mana() == 150 assert monster.Hp() == 300 - assert monster.Name() == 'Orc' + assert monster.Name() == b'Orc' assert monster.Color() == MyGame.Sample.Color.Color().Red assert monster.Pos().X() == 1.0 assert monster.Pos().Y() == 2.0 assert monster.Pos().Z() == 3.0 # Get and test the `inventory` FlatBuffer `vector`. - for i in xrange(monster.InventoryLength()): + for i in range(monster.InventoryLength()): assert monster.Inventory(i) == i # Get and test the `weapons` FlatBuffer `vector` of `table`s. - expected_weapon_names = ['Sword', 'Axe'] + expected_weapon_names = [b'Sword', b'Axe'] expected_weapon_damages = [3, 5] - for i in xrange(monster.WeaponsLength()): + for i in range(monster.WeaponsLength()): assert monster.Weapons(i).Name() == expected_weapon_names[i] assert monster.Weapons(i).Damage() == expected_weapon_damages[i] @@ -128,10 +128,10 @@ def main(): union_weapon = MyGame.Sample.Weapon.Weapon() union_weapon.Init(monster.Equipped().Bytes, monster.Equipped().Pos) - assert union_weapon.Name() == "Axe" + assert union_weapon.Name() == b"Axe" assert union_weapon.Damage() == 5 - print 'The FlatBuffer was successfully created and verified!' + print('The FlatBuffer was successfully created and verified!') if __name__ == '__main__': main()