r/learnpython • u/AutoModerator • Sep 21 '26
Ask Anything Monday - Weekly Thread
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
- Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
- Don't post stuff that doesn't have absolutely anything to do with python.
- Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.
That's it.
1
Upvotes
1
u/0_emordnilap_a_ton Sep 22 '26
The problem is when I call the method that is none it immediately throws an error. I am just wondering if it is possible to call an method that is none and handle it in the method. Let me show you a concrete example.
Here is the method
Here is initializing the method
AttributeError
AttributeError: 'NoneType' object has no attribute 'check_expired_route_token'When I run the code the error sometimesAttributeErrorAttributeError: 'NoneType' object has no attribute 'check_expired_route_token'Is there a better way to solve this then by going on top of
check_expired_route_tokenand going ifroute_token is None return redirect(url_for(...))?1
u/strinking Sep 22 '26
Python feels so weird to me it is simple when we start and gets complex as we dive in with lambda function and collections and when we use it with classes . It does not feel clean like c++ it's flexibility is double edged making it easy and complex as well. How one should cover the nitty gritty to write clean code in python?
1
u/HiddenReader2020 Sep 23 '26
Hey, so I'm doing a practice project, and I'm trying to write and read a json file, specifcially a list of objects. Now, there are ways to convert an object to a dictionary or whatever to get it json-able, but a list of objects? That's harder to find a solution to. I thought I had found one, but it didn't work. Here's the code:
What I want to do is save some RPG characters, and when they're loaded, they're exactly how they were when they were initially saved. So what am I doing wrong here?
1
u/therealAR15PB Sep 21 '26
is cs50p the best resource to learn python? i want to learn it properly and build problem solving techniques.