Static Data?
Stevie_mac
no.email at please.com
Sat Apr 10 14:55:23 EDT 2004
"Stevie_mac" <no.email at please.com> wrote in message news:2FTdc.56817$Id.5813 at news-binary.blueyonder.co.uk...
> I need to have a static class data member like c. How can I achieve this?
<SNIP>
Thanks all for your assistance. This though raised some question for me...
In Jeffs solution, Is self._ID the same variable as _ID (declared immediately after class Counted). Is there 3 _IDs?
If you have the time, could you explain (nothing fancy, just brief) the meaning of declaring variables in different
locations (like self, below class, as part of class, in a class def). This would be greatly appreciated.
and Peters solution
class Object:
_ID = 1
def __init__(self):
self.ID = Object._ID
Object._ID += 1
Is Object._ID a class instance variable and self.ID a 'shared' class variable
Cheers - Stevie_Mac (confused)
More information about the Python-list
mailing list