function without brackets ?
Carsten Haese
carsten at uniqsys.com
Wed Jan 3 09:47:44 EST 2007
On Wed, 2007-01-03 at 15:37 +0100, Stef Mientki wrote:
> If I call a parameterless function without brackets at the end,
> the function is not performed, but ...
> I don't get an error message ???
>
> Is this normal behavior ?
Yes. If you "call" a function without brackets, it's not a call.
Remember that functions are first class objects that can be passed
around like any other object. Hence, Python needs the distinction
between
x = foo() # Assign the *result* of calling foo to x
and
x = foo # Assign the *function* foo itself to x.
You don't get an error message because a function name without
parentheses is a valid expression that refers to that function.
Hope this helps,
Carsten.
More information about the Python-list
mailing list