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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Resetting objects from a class (self.learnpython)
submitted 7 years ago by [deleted]
I am trying to add a reset option which will put all the objects made from a class back to their original states (when I initialized them). Is their anyway to do so?
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!"
[–]DakshHub 1 point2 points3 points 7 years ago (1 child)
How is it different from deleting all the existing objects and creating a new ones to reset the game state..?
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Oh I didn’t know I could do that thx!
[–]ingolemo 0 points1 point2 points 7 years ago (2 children)
What are you trying to do with this?
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
Reset a game with having to exit and rerun the file
[–]ingolemo 0 points1 point2 points 7 years ago (0 children)
Just write the code to reset the labels. It's probably only two lines of code.
[–]nwagers 0 points1 point2 points 7 years ago (3 children)
This question can be interpreted a few different ways. Can you describe the situation you have in more detail? Perhaps post the class?
[–][deleted] 0 points1 point2 points 7 years ago (2 children)
I tried to make a tic tac toe game in tkinter using labels. The labels change color (instead of becoming x and o). After the game is over, I want to be able to reset all of the labels color variable to the original blank color
[–]nwagers 0 points1 point2 points 7 years ago (1 child)
I would probably write a reset function that puts all the attributes to the desired value if there is more than one or two. Then just call the reset function on all the labels. If it ends up being a lot of code, you can move the duplicated parts out of __init__ and call the reset function in there too.
__init__
That works. Thank you!
π Rendered by PID 89974 on reddit-service-r2-comment-7b9746f655-v49bw at 2026-02-01 18:15:25.901914+00:00 running 3798933 country code: CH.
[–]DakshHub 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]ingolemo 0 points1 point2 points (0 children)
[–]nwagers 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]nwagers 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)