UserLinux chooses Python as "interpretive language" of choice
fperez528 at yahoo.com
Tue Dec 23 02:53:31 CET 2003
John Roth wrote:
> Another is the pervasive use of the visitor pattern, and
> a third is the ability to forget the empty parenthesis after
> a function/method call that doesn't require parameters.
I briefly scanned the thread, and didn't see (perhaps I missed it) anyone
metioning how this collides with the whole 'callables as first class objects'
philosophy of python. Maybe I'm missing something (I don't know a thing about
Ruby, so I'll speak strictly from the python side), but if parens were
optional, how would the following work?
# Here I want the function
local_fn = some.nested.module.function
# Here I want the result
local_var = some.nested.module.function()
# do something
In this case, I DON'T want the function called, I just need to know if I have
Anyway, in my code I have tons of cases where I critically need to distinguish
between using a 'naked' function and calling it, and I find it always a
pleasure that in python, simply using () or not allows me to, unambiguously,
handle both cases. Perhaps there is an alternative which I haven't seen or
understood, but I'm genuinely interested in how you'd approach this issue if
the () were optional. I'm also curious about how it is handled in the Ruby
world, which as I said I'm not familiar with.
More information about the Python-list