diff options
author | chrismue <chregum@yahoo.de> | 2023-02-07 06:47:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-06 21:47:39 -0800 |
commit | 6af83a7d055a1f1a8698423455c66f26afed26f5 (patch) | |
tree | 1c0f594f3934a25a0a4a2da58913652b8d316bec | |
parent | 535ead8d8c93d5f7bd5c5c0707d7cb8e58afb34f (diff) | |
download | flatbuffers-6af83a7d055a1f1a8698423455c66f26afed26f5.tar.gz flatbuffers-6af83a7d055a1f1a8698423455c66f26afed26f5.tar.bz2 flatbuffers-6af83a7d055a1f1a8698423455c66f26afed26f5.zip |
Sample adjusted for Python3 (#7819)
Co-authored-by: chrismue <chrismue.gitlab@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
-rw-r--r-- | samples/sample_binary.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/samples/sample_binary.py b/samples/sample_binary.py index cd250a9c..09a239c2 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() |