Re: [pygame] Initializing and Reinitializing Instance variables

2019-05-25 Thread Irv Kalb
Thanks for the comments. Yes, there are many more variables than just the score. I just wanted to show one simple example to make the problem understandable. I hadn't thought of the extra "Session" object, it sounds like an interesting approach. However, I'm looking for a clear solution that

Re: [pygame] Initializing and Reinitializing Instance variables

2019-05-25 Thread mar77i
‐‐‐ Original Message ‐‐‐ On Saturday, May 25, 2019 8:55 PM, mspaintmaes...@gmail.com wrote: > For just a score variable, it's probably not a big deal to have an = 0 in > there twice as duplicate code, but games are complicated and so I'm sure > you've got lots of other fields as well,

Re: [pygame] Initializing and Reinitializing Instance variables

2019-05-25 Thread MrGumm
To satisfy PyCharm, which probably observes best practice, I just put all the attributes in __init__ with dummy or default values, and if they need to be reset I can implement a reset(). So what if it duplicates code and work? If it's a performance problem because the object is spammy, you can

Re: [pygame] Initializing and Reinitializing Instance variables

2019-05-25 Thread mspaintmaes...@gmail.com
For just a score variable, it's probably not a big deal to have an = 0 in there twice as duplicate code, but games are complicated and so I'm sure you've got lots of other fields as well, and that's where the duplication becomes problematic, especially if it's just there to appease the linter. I'm

[pygame] Initializing and Reinitializing Instance variables

2019-05-25 Thread Irv Kalb
Hi, I am teaching an Python object-oriented programming class based on my own materials. I am using Pygame to explain many OOP concepts. So far its going very well. I have built many small games as examples, but I keep running into a design dilemma. I will often have a class, where I have a