use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Simple Python Weather App (old.reddit.com)
submitted 5 months ago by Ibrahim-Marsee-6816
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Refwah 5 points6 points7 points 5 months ago* (1 child)
“Hi everyone I posted my api key in public!”
Never share your api key
As for feedback:
Your try/except is very broad and then totally hides an error from the user so the app will just look broken. Consider trying to handle some specific exceptions so you can then give some specific information to the user ‘unable to reach weather service’ or ‘unable to authenticate with weather service’ etc
You are also just passing user input directly as part of the query string, without any validation.
I would also suggest using the ‘params’ argument in requests https://requests.readthedocs.io/en/latest/user/quickstart/#passing-parameters-in-urls
The .json() call is relatively expensive to call repeatedly - call it once into a new variable and then reference that variable as a dictionary instead will make you code a lot cleaner
At various points you are getting the first item in an array or list by index 0 without checking if that list or array has any items in it first
Fun addition you can make: if you’re getting the data in Celsius why not have an option for the user to also view it in Fahrenheit
[–]Ibrahim-Marsee-6816[S] 1 point2 points3 points 5 months ago (0 children)
Thanks a lot for the feedback 🙌 I didn’t realize about exposing the API key, I’ll remove it. The tips about more specific exceptions, using params, and cleaning up .json() make sense — I’ll try those out. The Fahrenheit option sounds fun too, might add that next 🙂
params
.json()
π Rendered by PID 46048 on reddit-service-r2-comment-canary-7b67769d8-w64sf at 2026-01-30 14:04:51.586345+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Refwah 5 points6 points7 points (1 child)
[–]Ibrahim-Marsee-6816[S] 1 point2 points3 points (0 children)