overload operator()?

brucedickey brucedickey at micron.com
Mon Dec 16 15:16:15 EST 2002


Thank you! Guess I should have said overridden, but you understood.

Bruce

-----Original Message-----
From: John Hunter [mailto:jdhunter at ace.bsd.uchicago.edu]
Sent: Monday, December 16, 2002 1:13 PM
To: Bruce Dickey
Cc: python-list at python.org
Subject: Re: overload operator()?


>>>>> "Bruce" == Bruce Dickey <brucedickey at micron.com> writes:

    Bruce> Is there a way to overload () in Python to call a
    Bruce> user-defined function?  I've overloaded + | ~ etc, but ()
    Bruce> has me stumped.


See  http://www.python.org/doc/current/ref/specialnames.html

class callme:

    def __call__(self):
        print 'hi'

f = callme()
f()


John Hunter




More information about the Python-list mailing list