Re: python newbie
- From: Duncan Booth <duncan.booth@xxxxxxxxxxxxxxx>
- Date: 5 Nov 2007 09:06:05 GMT
Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
As far as I know, all it would take to allow modules to be callable
would be a single change to the module type, the equivalent of:
def __call__(self, *args, **kwargs):
try:
# Special methods are retrieved from the class, not
# from the instance, so we need to see if the
# instance has the right method.
callable = self.__dict__['__call__']
except KeyError:
return None # or raise an exception?
return callable(self, *args, **kwargs)
The error should throw "TypeError: 'module' object is not callable" just as
it does today.
Also, it shouldn't pass self through to callable: modules have functions
not methods.
.
- References:
- python newbie
- From: Jim Hendricks
- Re: python newbie
- From: Bjoern Schliessmann
- Re: python newbie
- From: Bruno Desthuilliers
- Re: python newbie
- From: Hendrik van Rooyen
- Re: python newbie
- From: Steven D'Aprano
- Re: python newbie
- From: Duncan Booth
- Re: python newbie
- From: Paul Rubin
- Re: python newbie
- From: Duncan Booth
- Re: python newbie
- From: Paul Rubin
- Re: python newbie
- From: Paul Hankin
- Re: python newbie
- From: Paul Rubin
- Re: python newbie
- From: Bruno Desthuilliers
- Re: python newbie
- From: Paul Rubin
- Re: python newbie
- From: Bruno Desthuilliers
- Re: python newbie
- From: Paul Rubin
- Re: python newbie
- From: Steven D'Aprano
- python newbie
- Prev by Date: parsing string to a list of objects - help!
- Next by Date: Re: __file__ vs __FILE__
- Previous by thread: Re: python newbie
- Next by thread: Re: python newbie
- Index(es):