Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Guido van Rossum
On Wed, Feb 4, 2009 at 11:48 AM, "Martin v. Löwis" wrote: >> If there is interest in this and no reason why it shouldn't be done, I >> can write up an issue in the tracker and provide a patch. > > I think there is a tricky design choice to make wrt. argument passing. > IIUC, you don't care much ab

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Steven Bethard
On Wed, Feb 4, 2009 at 10:50 AM, Brett Cannon wrote: > On Wed, Feb 4, 2009 at 10:43, Steven Bethard wrote: >> Not sure I follow you here. It's not the __init__ that allows you to >> do ``x()``, it's the fact that the class declares a __call__, right? >> > class C(object): >> ... pass >> .

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Jean-Paul Calderone
On Wed, 4 Feb 2009 10:50:47 -0800, Brett Cannon wrote: On Wed, Feb 4, 2009 at 10:43, Steven Bethard wrote: [snip] Not sure I follow you here. It's not the __init__ that allows you to do ``x()``, it's the fact that the class declares a __call__, right? class C(object): ... pass ... C._

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Martin v. Löwis
> If there is interest in this and no reason why it shouldn't be done, I > can write up an issue in the tracker and provide a patch. I think there is a tricky design choice to make wrt. argument passing. IIUC, you don't care much about arguments, so you could probably live with def call(o): r

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Guido van Rossum
I believe the omission of call from the operator module is an oversight, perhaps caused by the existence (when the operator module was created) of apply. Since apply has been removed from 3.0, we should add operator.call (with the same signature) back. It should be a straightforward wrapper around

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Brett Cannon
On Wed, Feb 4, 2009 at 10:43, Steven Bethard wrote: > On Wed, Feb 4, 2009 at 10:25 AM, Brett Cannon wrote: >> On Wed, Feb 4, 2009 at 05:35, Hrvoje Niksic wrote: >>> Andrew Bennetts wrote: A patch to add operator.caller(*args, **kwargs) may be a good idea. Your example would then

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Steven Bethard
On Wed, Feb 4, 2009 at 10:25 AM, Brett Cannon wrote: > On Wed, Feb 4, 2009 at 05:35, Hrvoje Niksic wrote: >> Andrew Bennetts wrote: >>> >>> A patch to add operator.caller(*args, **kwargs) may be a good idea. Your >>> example would then be: >>> >>>map(operator.caller(), lst) >> >> Regarding t

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Brett Cannon
On Wed, Feb 4, 2009 at 05:35, Hrvoje Niksic wrote: > Andrew Bennetts wrote: >> >> A patch to add operator.caller(*args, **kwargs) may be a good idea. Your >> example would then be: >> >>map(operator.caller(), lst) > > Regarding the name, note that I proposed operator.call (and > operator.__ca

Re: [Python-Dev] [patch] Duplicate sections detection in ConfigParser

2009-02-04 Thread Yannick Gingras
On Tuesday 03 February 2009, Raghuram Devarakonda wrote: > http://bugs.python.org/issue2204 refers to the same issue. Perhaps, > you can upload your patch there in addition to adding any comments. I attached the patch to the ticket. Do you have recommendations on how to solve the uniformity issue

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Hrvoje Niksic
Nick Coghlan wrote: I'm somewhere between -0 and +0 though (-0 due to the lack of concrete use cases, +0 because the improved consistency is appealing) The operator module is one of the rare cases in python where consistency is valued more than concrete use cases. But, for what it's worth, I

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Hrvoje Niksic
Andrew Bennetts wrote: A patch to add operator.caller(*args, **kwargs) may be a good idea. Your example would then be: map(operator.caller(), lst) Regarding the name, note that I proposed operator.call (and operator.__call__) because it corresponds to the __call__ special method, which

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Nick Coghlan
Hrvoje Niksic wrote: > Is there a reason why the operator module doesn't have an operator.call > function? My guess is that it was left out because it would have been redundant given the existence of apply() in 2.x. That argument no longer holds in 3.x of course, so operator.call may be a reasona

Re: [Python-Dev] Missing operator.call

2009-02-04 Thread Andrew Bennetts
Hrvoje Niksic wrote: > Is there a reason why the operator module doesn't have an operator.call > function? Python 2.6 adds operator.methodcaller. So you could use operator.methodcaller('__call__'), but that's not really any better than lambda x: x(). A patch to add operator.caller(*args, **kwa

[Python-Dev] Missing operator.call

2009-02-04 Thread Hrvoje Niksic
Is there a reason why the operator module doesn't have an operator.call function? It would seem logical to be able to write: map(operator.call, lst) which calls each object in lst, just like map(operator.neg, lst) negates every object. Of course, operator.call is equivalent to lambda x: x(),

Re: [Python-Dev] C API for appending to arrays

2009-02-04 Thread Hrvoje Niksic
Mike Klaas wrote: Do you need to append, or are you just looking to create/manipulate an array with a bunch of c-float values? Mostly real-life examples I've seen of this were creating an array from C values obtained from an external source, such as an on-disk file, or another process. The

Re: [Python-Dev] teaching the new urllib

2009-02-04 Thread python-3000
On Tue, Feb 03, 2009 at 06:50:44PM -0500, Tres Seaver wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > The encoding information *is* available in the response headers, e.g.: > > - -- %< - > $ wget -S --spider http://knuth.luther.e