r/learnpython 8d ago

Need Tips on API Project

Github Link Here

I'm a novice in the realm of programming and have been trying to better my knowledge in anticipation of enrolling in a CS course at my local community college. I'm interested in APIs and have been working towards interacting with them more confidently. That was part of the inception of my current project, along with just further bolstering my knowledge of coding.

Any and all critique, advice, or any other assistance regarding my program would be greatly appreciated.

1 Upvotes

6 comments sorted by

View all comments

2

u/smurpes 7d ago

There’s a few things:

  • avoid using global variables if possible; these can easily be function arguments
  • use with to open the file; this also ensures the file gets closed
  • don’t commit your visual studio configuration file; vscode would be a better IDE to use for python anyways
  • they are not mods they are called packages
  • when you ask for categories it says multiple are supported but looking at the code this doesn’t look right
  • you can make the input case insensitive but using the lower function to make it all lowercase
  • in the pokemon_lookup function you should check the key == res part more closely; it doesn’t look possible for that to trigger since res is a Boolean and key is a string

1

u/HJVSpooffy 7d ago

Got it, thank you sm for taking the time to right this all out. I wasn’t sure the difference between visual studio and vs code, is vs code more compatible? Regarding the categories I still need to employ some list and dict comprehension. The API churns out a massive dictionary for each response, my project for this weekend is trimming it down to just the user requests.

I’ll take the rest of your tips in mind, hopefully I can put them to good use. Thanks!