On Jul 30, 12:14 pm, r <rt8...@gmail.com> wrote: > On Jul 30, 1:13 pm, NighterNet <darkne...@gmail.com> wrote: > > > Need some help on doing some bit simple id count. It like every time > > it create a class orthreadthere is id++. Python 3.1 > > > example: > > class ClientThread (threading.Thread): > > def __init__(self,clientSocket): > > threading.Thread.__init__(self) > > self.id += 1; > > > Not sure it how it works. > > use a class atrribute > > >>> class Person(): > > count = 0 > def __init__(self, name, info): > self.name = name > self.info = info > Person.count+=1 > > >>> p1 = Person('alex23', 'very annoying') > >>> p2 = Person('Guido', 'very intelligent') > >>> p2.count > 2 > >>> p1.count > 2 > >>> Person.count > > 2
Thanks it work. class Person(): count = 0 def __init__(self, name, info): self.name = name self.info = info Person.count+=1 self.count = Person.count -- http://mail.python.org/mailman/listinfo/python-list