[Tutor] classes and the deepcopy function
alan.gauld at btinternet.com
Sat Jan 5 10:09:48 CET 2008
"Michael" <python at mrfab.info> wrote
> Is it normal practice to declare your variables in a class? I notice
> that you don't have to, you can create them as you go, but i thought
> declaring and initialising them in the class would make it easier to
> understand and see what the class is for and should contain.
Its normal to declare them in the definition. Its just that instance
variables go in the init method whereas class variables go in the
class scope and are, as you say, shatred by all instances.
Author of the Learn to Program web site
More information about the Tutor