Re: __call__
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: __call__

From: TK <merman@o2online.de>
Date: Sat May 28 2005 - 22:02:33 CEST

Simon Percivall wrote:
> Look at http://docs.python.org/ref/callable-types.html
>
>
>>>>class Test(object):
>
> ... def __call__(self):
> ... print "the instance was called"
> ...
>
>>>>t = Test()
>>>>t()
>
> the instance was called
>
> Is this what you wanted?

Sorry but it does not work. Here's my code:

>>> class Test(object):
... def __call__(self):
... print 'Hi'
...
>>> Test()
<__main__.Test object at 0x3e6d0>

o-o

Thomas
Received on Thu Sep 29 16:15:37 2005