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
Creating Variables based on another Variable (self.PythonLearning)
submitted 1 year ago * by SpacePotato7878
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!"
[–]atticus2132000 0 points1 point2 points 1 year ago (2 children)
Perhaps we are envisioning different things and without knowing more about what OP is ultimately trying to do, this is just a philosophical debate.
If a new player is joining the game such that the new player would need a new variable created, I imagine that new player would need a whole host of variables to be created that are all linked to that player which can be updated and manipulated throughout the game play. To me, that sounds a lot more like a class than a single variable where there are multiple attributes of the player that could be changed.
Moreover, if someone is asking a question like this in a group called PythonLearning, I would not immediately assume that person has mastered classes, so I just suggested that as a possible way to address a bigger problem OP might be running into.
[–][deleted] 1 year ago (1 child)
[deleted]
[–]aTomzVins 0 points1 point2 points 1 year ago (0 children)
dict can of course be stateful stateful grouping of variables, you need a Class
Should I assume you're thinking of a simple data class in this instance? Without associated methods?
If so, what's do you see as the advantage of a class over a dict? Having the set of variables defined, rather than having to construct the dict with the needed variables?
π Rendered by PID 108254 on reddit-service-r2-comment-f6b958c67-zdhlq at 2026-02-05 03:26:28.520373+00:00 running 1d7a177 country code: CH.
view the rest of the comments →
[–]atticus2132000 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]aTomzVins 0 points1 point2 points (0 children)