forgetting () after function

Michal Bozon bozon at natur.cuni.cz
Mon Mar 13 19:45:30 CET 2000


> 
> I've noticed that if you inadvertantly omit the () at the end of a
> function call (that does not need params), python just ignores it, no
> warning, no nothing. Does anyone know of a way to catch this somehow to
> avoid insidious logic errors that could result, or protect your program
> from blowing up down the line?
> 

If you have a function without arguments, e.g. f(), and you type:
>>> g = f
it means, that g is not a result of function f, but it is also a function.
So you can type
>>> v = g()
this is same as
>>> v = f()

Michal Bozon
Faculty of Science, Charles Univ., Prague, Czech Rep.
bozon at natur.cuni.cz
http://www.natur.cuni.cz/~bozon




More information about the Python-list mailing list