--
____________________________________________________________________________
Kia A. Arab, Software Test Engineer
Space Telescope Science Institute
Engineering & Software Services Division/Software Testing Team
EMAIL: ka...@stsci.edu PHONE: 410-516-8597
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.
bo...@natur.cuni.cz
http://www.natur.cuni.cz/~bozon
> 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.
That is not exactly true. If you have a function 'spam', then
spam()
-> evaluates to the value returned by the function
(executes the function to get this value, of course)
spam
-> evaluates to the function itself
This is intentional and useful. Functions are first-class objects in Python.
> 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?
Test your programs?
Seriously, I can't think of much you can directly do to 'catch this',
since people may use this part of the language correctly and intentionally.
-Justin