[Tutor] decorators, __call__ (able) objects

vince spicer vinces1979 at gmail.com
Wed Jul 15 16:22:14 CEST 2009


simple example of calling a class

class myKlass(object):

    def __call__(self, *args, **kws):
         print "i was called"


>> test = myKlass()

>> test()

>> i was called


>
>
>
> On Wed, Jul 15, 2009 at 6:33 AM, Kent Johnson <kent37 at tds.net> wrote:
>
>> On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto<tmatsumoto at gmx.net>
>> wrote:
>> > Hi,
>> >
>> > Can some one give, or point to some good examples of how @decorators
>> work, and __call__ (able) objects?
>>
>> Decorators:
>> http://personalpages.tds.net/~kent37/kk/00001.html<http://personalpages.tds.net/%7Ekent37/kk/00001.html>
>>
>> Kent
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090715/7ed8fef8/attachment.htm>


More information about the Tutor mailing list