On Thu, 11 Mar 2010 07:56:59 -0500, Neal Becker wrote:
> The example I showed was just a toy problem. The real problem is I
> expect to call a function many times, and I want to avoid the overhead
> of the 'if blah' everytime.
Unless the __call__ methods are very small, the overhead of one extra
On Thu, 11 Mar 2010 08:20:14 -0800, Steve Howell wrote:
>> (2) special methods like __call__ are only called on the class, not the
>> instance, so you can't give each instance its own method.
>>
>>
> Are you sure about that? This program prints 1, 2, 1, 2.
The rules for classic classes are diffe
Steve Howell wrote:
> On Mar 10, 7:18 pm, Steven D'Aprano
> wrote:
>> (2) special methods like __call__ are only called on the class, not the
>> instance, so you can't give each instance its own method.
> Are you sure about that? This program prints 1, 2, 1, 2.
You are using a classic class
On Mar 10, 7:18 pm, Steven D'Aprano
wrote:
> On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote:
> > Want to switch __call__ behavior. Why doesn't this work? What is the
> > correct way to write this?
>
> > class X (object):
> > def __init__(self, i):
> > if i == 0:
> >
Andre Engels wrote:
On Thu, Mar 11, 2010 at 2:30 PM, Steve Holden wrote:
The example I showed was just a toy problem. The real problem is
I expect to call a function many times, and I want to avoid the overhead of
the 'if blah' everytime.
This is a premature optimization. First, make it wor
On Thu, Mar 11, 2010 at 2:30 PM, Steve Holden wrote:
>> The example I showed was just a toy problem. The real problem is
>> I expect to call a function many times, and I want to avoid the overhead of
>> the 'if blah' everytime.
>>
> This is a premature optimization. First, make it work. Then (if
Neal Becker wrote:
> Steven D'Aprano wrote:
>
>> On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote:
>>
>>> Want to switch __call__ behavior. Why doesn't this work? What is the
>>> correct way to write this?
>>>
>>> class X (object):
>>> def __init__(self, i):
>>> if i == 0:
>>>
Steven D'Aprano wrote:
> On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote:
>
>> Want to switch __call__ behavior. Why doesn't this work? What is the
>> correct way to write this?
>>
>> class X (object):
>> def __init__(self, i):
>> if i == 0:
>> def __call__ (self)
On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote:
> Want to switch __call__ behavior. Why doesn't this work? What is the
> correct way to write this?
>
> class X (object):
> def __init__(self, i):
> if i == 0:
> def __call__ (self):
> return 0
>
Robert Kern wrote:
> On 2010-03-10 12:23 PM, Neal Becker wrote:
>> Duncan Booth wrote:
>> ...
>>>
>>> P.S. I don't know what you did in your post but your Followup-To header
>>> is pointing to a group on gmane which makes extra work for me replying.
>>> Please don't do that.
>>
>> I'm sorry about
On 2010-03-10 12:23 PM, Neal Becker wrote:
Duncan Booth wrote:
...
P.S. I don't know what you did in your post but your Followup-To header is
pointing to a group on gmane which makes extra work for me replying.
Please don't do that.
I'm sorry about that, there is some bad interaction between
On 2010-03-10 13:42 PM, Neal Becker wrote:
Duncan Booth wrote:
Neal Becker wrote:
Duncan Booth wrote:
...
P.S. I don't know what you did in your post but your Followup-To
header is pointing to a group on gmane which makes extra work for me
replying. Please don't do that.
I'm sorry about
Duncan Booth wrote:
> Neal Becker wrote:
>
>> Duncan Booth wrote:
>> ...
>>>
>>> P.S. I don't know what you did in your post but your Followup-To
>>> header is pointing to a group on gmane which makes extra work for me
>>> replying. Please don't do that.
>>
>> I'm sorry about that, there is so
Neal Becker wrote:
> Duncan Booth wrote:
> ...
>>
>> P.S. I don't know what you did in your post but your Followup-To
>> header is pointing to a group on gmane which makes extra work for me
>> replying. Please don't do that.
>
> I'm sorry about that, there is some bad interaction between gmane'
Duncan Booth wrote:
...
>
> P.S. I don't know what you did in your post but your Followup-To header is
> pointing to a group on gmane which makes extra work for me replying.
> Please don't do that.
I'm sorry about that, there is some bad interaction between gmane's nntp-
smtp gateway and python's
Neal Becker wrote:
> What I'm trying to do is make a callable whose behavior is switched
> based on some criteria that will be fixed for all calls. In my
> example, this will ultimately be determined by the setting of a
> command line switch.
>
If you want different behaviour its usually best
Neal Becker wrote:
> Simon Brunning wrote:
>
>> On 10 March 2010 13:12, Neal Becker wrote:
>>> Want to switch __call__ behavior. Why doesn't this work? What is the
>>> correct way to write this?
>>>
>>> class X (object):
>>> def __init__(self, i):
>>> if i == 0:
>>> def __call__ (self):
>>> ret
Simon Brunning wrote:
> On 10 March 2010 13:12, Neal Becker wrote:
>> Want to switch __call__ behavior. Why doesn't this work? What is the
>> correct way to write this?
>>
>> class X (object):
>> def __init__(self, i):
>> if i == 0:
>> def __call__ (self):
>> return 0
>> else:
>> def __call_ (s
Neal Becker wrote:
Want to switch __call__ behavior. Why doesn't this work? What is the
correct way to write this?
class X (object):
def __init__(self, i):
if i == 0:
def __call__ (self):
return 0
else:
def __call_ (self):
On 10 March 2010 13:12, Neal Becker wrote:
> Want to switch __call__ behavior. Why doesn't this work? What is the
> correct way to write this?
>
> class X (object):
> def __init__(self, i):
> if i == 0:
> def __call__ (self):
> return 0
> else:
>
Want to switch __call__ behavior. Why doesn't this work? What is the
correct way to write this?
class X (object):
def __init__(self, i):
if i == 0:
def __call__ (self):
return 0
else:
def __call_ (self):
return 1
x =
21 matches
Mail list logo