module with __call__ defined is not callable?

Antoon Pardon apardon at forel.vub.ac.be
Wed Feb 8 09:23:19 EST 2006


Op 2006-02-08, Steve Holden schreef <steve at holdenweb.com>:
> Fuzzyman wrote:
>> Steve Holden wrote:
> [...]
>>>
>>>The pursuit of orthogonality, while admirable, can lead to insanity if
>>>pushed too far.
>>>
>> 
>> 
>> Sure - feel free to venture as far down the road of insanity as you
>> like :-) To pursue your analogy, why don't we answer all usenet posts
>> by pushing suggestions to ridiculous levels ? ;-)
>> 
> Right, and publish cartoons of Larry Wall where his hat is a bomb. Then 
> the perlmongers will burn the Googleplex down?
>
>> What would actually be the problem with allowing modules to define a
>> __call__ though ? This would allow for nice clean namespaces at the
>> module level.
>> 
> What's clean about defining __call__() and calling the module name 
> rather than defining functions and calling them?

The same question can be asked about classes? What's clean about
defining a __call__() method and calling the instance name rather
than defining methods and calling them?

> Why should one specific 
> function in a module be promoted to this special status? How many 
> modules have precisely one function?

For the same reason they are already promoted special status in
classes. Python promotes duck typing so why shouldn't special
functions of modules be treated the same as special methods?

-- 
Antoon Pardon



More information about the Python-list mailing list