Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sprites.versions all have dashes in their names #44

Open
axiopaladin opened this issue Jul 31, 2023 · 1 comment
Open

sprites.versions all have dashes in their names #44

axiopaladin opened this issue Jul 31, 2023 · 1 comment

Comments

@axiopaladin
Copy link

If I wanted to get, say, the Gen 4 sprite of Pikachu, my first instinct would be the following:

import pokebase as pb
pikachu = pb.pokemon("pikachu")
pikachu_sprite = pikachu.sprites.versions.generation-iv.front_default

However, notice that generation-iv has a hyphen. According to the python interpreter, that's a subtraction operator, and it throws an error because it doesn't know how to subtract iv.front_default (an object that doesn't exist) from pikachu.sprites.versions.generation (which also doesn't exist).

The simplest fix would probably be to change all generation calls to use underscores instead.

@jemarq04
Copy link

One way to get around this is to use getattr. For this example, you could get around it by saying

import pokebase as pb
pikachu = pb.pokemon("pikachu")
pikachu_sprite = getattr(pikachu.sprites.versions, "generation-iv").front_default

Though, you'd need to specify a version group in between since generation-iv leads to diamond-pearl, platinum, and heartgold-soulsilver. For the version groups that have dashes, you'd have to use another getattr call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants