This coding style bad practise?
me+python at modelnine.org
Thu May 4 04:03:24 CEST 2006
Am Donnerstag 04 Mai 2006 01:04 schrieb Martin P. Hellwig:
> Because of:
> >>>> id = IDGenerator("01",99)
> >>>> id()
> > Traceback (most recent call last):
> > File "<pyshell#1>", line 1, in ?
> > id()
> > TypeError: 'IDGenerator' object is not callable
> But i do appreciate your comment, thanks!
You need to define a __call__(self)-method on your class so that instances are
callable... Basically, what Bruno was saying, is that you rename your
__repr__(self) to __call__(self), and see what happens.
More information about the Python-list