Issue 54 in tinypy: __call__ method cannot be defined for objects

29 views
Skip to first unread message

codesite...@google.com

unread,
Dec 16, 2012, 5:56:08 AM12/16/12
to tin...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 54 by RCopperw...@gmail.com: __call__ method cannot be defined
for objects
http://code.google.com/p/tinypy/issues/detail?id=54

What steps will reproduce the problem?

1. Create a class with a __call__(self) method
2. Instantiate it
3. Attempt to call the instance

class Test:
def __call__(self):
print("hello world")

instance = Test()
instance()

What is the expected output? What do you see instead?

This code is expected to print "hello world", but it produces nothing. If
you were to add the line instance2 = instance() and then query the value of
instance2, you would see that instance2 is another Test object. Tinypy is
not calling the __call__ method of the instance, but actually calling the
__call__ method of the CLASS, ( i.e. Test() )


Reply all
Reply to author
Forward
0 new messages