Re: module with __call__ defined is not callable?

2006-02-10 Thread Bengt Richter
On Thu, 9 Feb 2006 10:07:49 +1100, "Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: >Steven D'Aprano wrote: > >> That's not a _reason_, it is just a (re-)statement of fact. We know >> that defining a __call__ method on a module doesn't make it callable. >> Why not? The answer isn't "because de

Re: module with __call__ defined is not callable?

2006-02-10 Thread Steven D'Aprano
On Wed, 08 Feb 2006 07:14:04 -0500, Steve Holden wrote: >>>Someone had to code Python so that it raised an error when you try to call >>>a module object. Is there a reason why module() should not execute >>>module.__call__()? I would have thought that by the duck typing principle, >>>it shouldn't

Re: module with __call__ defined is not callable?

2006-02-09 Thread Scott David Daniels
Kent Johnson wrote: > Antoon Pardon wrote: >> This make me wonder. Would it be possible to do something with >> metaclasses so that after >> >> class SomeClass(MetaClass): >> ... >> >> SomeClass() will be equivalent to MetaClass.__call__(SomeClass) > > I think that's already what happ

Re: module with __call__ defined is not callable?

2006-02-09 Thread Kent Johnson
Antoon Pardon wrote: > This make me wonder. Would it be possible to do something with > metaclasses so that after > > class SomeClass(MetaClass): > ... > > SomeClass() will be equivalent to MetaClass.__call__(SomeClass) I think that's already what happens. IIUC type.__call__ implem

Re: module with __call__ defined is not callable?

2006-02-09 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Right. While we're at it, why don't we make strings callable. Calling > a string could call the function whose name (in some namespace or > other) was in the string. Making a string subclass callable works fine: >>> class f(str): ... def __cal

Re: module with __call__ defined is not callable?

2006-02-09 Thread Antoon Pardon
Op 2006-02-08, Scott David Daniels schreef <[EMAIL PROTECTED]>: > Steven D'Aprano wrote: >> On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: >> >>> adam johnson wrote: >>> Hi All. I was wondering why defining a __call__ attribute for a module doesn't make it actuall

Re: module with __call__ defined is not callable?

2006-02-09 Thread Antoon Pardon
Op 2006-02-08, Steve Holden schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2006-02-08, Steve Holden schreef <[EMAIL PROTECTED]>: >> >>>Why should a module be callable? What's the advantage? Should we be able >>>to add two modules together, yielding a module that contains all the >>>co

RE: module with __call__ defined is not callable?

2006-02-08 Thread Delaney, Timothy (Tim)
Steven D'Aprano wrote: > That's not a _reason_, it is just a (re-)statement of fact. We know > that defining a __call__ method on a module doesn't make it callable. > Why not? The answer isn't "because defining a __call__ method on a > module or an instance doesn't make it callable", that's just a

Re: module with __call__ defined is not callable?

2006-02-08 Thread Steve Holden
Antoon Pardon wrote: > Op 2006-02-08, Steve Holden schreef <[EMAIL PROTECTED]>: > >>Why should a module be callable? What's the advantage? Should we be able >>to add two modules together, yielding a module that contains all the >>code of both modules? What happens if I multiply a module by two -

Re: module with __call__ defined is not callable?

2006-02-08 Thread Scott David Daniels
Steven D'Aprano wrote: > On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: > >> adam johnson wrote: >> >>> Hi All. >>> I was wondering why defining a __call__ attribute for a module >>> doesn't make it actually callable. >> For the same reason that the following doesn't work > [sn

Re: module with __call__ defined is not callable?

2006-02-08 Thread Antoon Pardon
Op 2006-02-08, Steve Holden schreef <[EMAIL PROTECTED]>: > > Why should a module be callable? What's the advantage? Should we be able > to add two modules together, yielding a module that contains all the > code of both modules? What happens if I multiply a module by two - > presumably the resul

Re: module with __call__ defined is not callable?

2006-02-08 Thread Antoon Pardon
Op 2006-02-08, Steve Holden schreef <[EMAIL PROTECTED]>: > 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 :-) T

Re: module with __call__ defined is not callable?

2006-02-08 Thread bruno at modulix
Steve Holden wrote: (snip) > The pursuit of orthogonality, while admirable, can lead to insanity if > pushed too far. > +1 QOTW -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailm

Re: module with __call__ defined is not callable?

2006-02-08 Thread Steve Holden
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 pushi

Re: module with __call__ defined is not callable?

2006-02-08 Thread Fuzzyman
Steve Holden wrote: > Fuzzyman wrote: > > Steven D'Aprano wrote: > > > >>On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: > >> > >> > >>>adam johnson wrote: > >>> > >>> > Hi All. > I was wondering why defining a __call__ attribute for a module > doesn't make it actuall

Re: module with __call__ defined is not callable?

2006-02-08 Thread Steve Holden
Fuzzyman wrote: > Steven D'Aprano wrote: > >>On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: >> >> >>>adam johnson wrote: >>> >>> Hi All. I was wondering why defining a __call__ attribute for a module doesn't make it actually callable. >>> >>>For the same reason that

Re: module with __call__ defined is not callable?

2006-02-08 Thread Fuzzyman
Steven D'Aprano wrote: > On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: > > > adam johnson wrote: > > > >> Hi All. > >> I was wondering why defining a __call__ attribute for a module > >> doesn't make it actually callable. > > > > For the same reason that the following doesn't w

RE: module with __call__ defined is not callable?

2006-02-08 Thread Steven D'Aprano
On Wed, 08 Feb 2006 13:58:13 +1100, Delaney, Timothy (Tim) wrote: > adam johnson wrote: > >> Hi All. >> I was wondering why defining a __call__ attribute for a module >> doesn't make it actually callable. > > For the same reason that the following doesn't work [snip example] > The __call__ attr

Re: module with __call__ defined is not callable?

2006-02-07 Thread limodou
On 2/8/06, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote: > limodou wrote: > > > On 2/8/06, adam johnson <[EMAIL PROTECTED]> wrote: > >> Thanks for you answer. > >> > >> I was under the impression that you could tack methods onto an > >> object at any time, your example almost works with old sty

RE: module with __call__ defined is not callable?

2006-02-07 Thread Delaney, Timothy (Tim)
limodou wrote: > On 2/8/06, adam johnson <[EMAIL PROTECTED]> wrote: >> Thanks for you answer. >> >> I was under the impression that you could tack methods onto an >> object at any time, your example almost works with old style classes >> and would with a function instead of a method. In fact it

Re: module with __call__ defined is not callable?

2006-02-07 Thread limodou
On 2/8/06, adam johnson <[EMAIL PROTECTED]> wrote: > Thanks for you answer. > > I was under the impression that you could tack methods onto an object at any > time, your example almost works with old style classes and would with a > function instead of a method. > > >>> class A: > ... def __ini

Re: module with __call__ defined is not callable?

2006-02-07 Thread adam johnson
Thanks for you answer.I was under the impression that you could tack methods onto an object at any time, your example almost works with old style classes and would with a function instead of a method.>>> class A: ... def __init__(self):... self.__call__ = A.hello... def hello(se

Re: module with __call__ defined is not callable?

2006-02-07 Thread limodou
On 2/8/06, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote: > adam johnson wrote: > > > Hi All. > > I was wondering why defining a __call__ attribute for a module > > doesn't make it actually callable. > > For the same reason that the following doesn't work > > class A (object): > > de

RE: module with __call__ defined is not callable?

2006-02-07 Thread Delaney, Timothy (Tim)
adam johnson wrote: > Hi All. > I was wondering why defining a __call__ attribute for a module > doesn't make it actually callable. For the same reason that the following doesn't work class A (object): def __init__(self): self.__call__ = A.hello def hello (self

Re: module with __call__ defined is not callable?

2006-02-07 Thread limodou
On 2/8/06, adam johnson <[EMAIL PROTECTED]> wrote: > Hi All. > I was wondering why defining a __call__ attribute for a module doesn't make > it actually callable. > > I don't have any reason for doing so, I was just wondering if it worked, and > found out it didn't. > > $ cat mod.py > """ > Test ca