|
Some general programming questions in python
I have a few general programming questions. But since there isn't a general programming section, and I'm using python, I figured I'd post them here.
First off, say my program is a game. The user is asked to and selects defend. In order to defend, a variable is changed to true. Which is of course, a single line of code. Does it make difference performance or design wise, if that line is in the input function that asked the player to defend? or if it's in its very own defend function?
Now on to classes. I understand how classes are used for inheritance, polymorphisms and so on. What I never understood is, are they suppose to be used for organization also? Even if a function or something, doesn't really need to be in a class, should it be?
Also, should I put my variables that are used by multiple function, inside a class that they are at least somewhat related to, so I can use there scope to change them, instead of making them global? Would that be more efficient?
And lastly, should comments that are related to something like a variable be placed beside it or above it? And for multi-line comments, should I use triple quotes, or a # sign at the begging of each line?
__________________
"Gee, Brain, what do you want to do tonight?" "The same thing we do every night, Pinky: Try to take over the world!"
|