strange __call__

Rahul codedivine at
Wed Jun 29 02:12:59 CEST 2005

Consider the following:
def a(x):
 return x+1

def b(f):
  def g(*args,**kwargs):
    for arg in args:
        print arg
    return f(*args,**kwargs)
  return g

a.__call__ = b(a.__call__)

now calling a(1) and a.__call__(1) yield 2 different results!!
i.e. for functions a(1) doesnt seem to be translated to a.__call__ if
you assign a new value to a.__call__?
i am using python 2.3.3 
somebody please clear this confusion

More information about the Python-list mailing list