Forgetting "()" when calling methods

Frantisek Fuka fuka at fuxoft.cz
Fri Apr 25 23:46:50 CEST 2003


When I try to call methods, I sometimes forget to include the 
parentheses. Instead of:

if object.isGreen():
	do something...

i sometimes write:

if object.isGreen:
	do something...

If I understand it correctly, the if statement in this case tests if 
pointer to hasParent method is non-zero, which is of course always True 
so no error is reported and "do something..." always gets executed, so 
the application behaves in quite different way than I expected.

You can say to me "Don't forget to always include the parenteses" but 
I'm still curious if this cannot be somehow configured, so that I get 
error when I try to just access the method pointer (".isGreen") instead 
of calling the method (".isGreen()"). I understand that there has to be 
the possibility of accessing the method pointers but I usually don't 
need it and for a beginner like me this makes the applications very hard 
to debug.





More information about the Python-list mailing list