This coding style bad practise?
Heiko Wundram
me+python at modelnine.org
Wed May 3 22:03:24 EDT 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.
--- Heiko.
More information about the Python-list
mailing list