Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Raymond Hettinger
Instead of a separate function in collections, it may be sensible to stick with the familiar and provide a dictionary contructor for the commonly encounter use case of counting things: @classmethod def fromcount(cls, iterable): d = cls() for elem in iterable: d[elem] = d.get(elem,

[Python-Dev] concerns regarding callable() method

2007-04-08 Thread Paul Pogonyshev
Hi, I have seen in PEP 3100 that callable() function is planned to be removed in Python 3000 with this replacement: "just call the object and catch the exception???". For one, the object (if it is callable) can raise exception itself, so you need to somehow to differentiate between exception rais

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Andrew Koenig
> I have seen in PEP 3100 that callable() function is planned to be > removed in Python 3000 with this replacement: "just call the object > and catch the exception???". For one, the object (if it is > callable) can raise exception itself, so you need to somehow to > differentiate between exception

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Guido van Rossum
On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > I have seen in PEP 3100 that callable() function is planned to be > removed in Python 3000 with this replacement: "just call the object > and catch the exception???". For one, the object (if it is > callable) can raise exception itself, so yo

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Paul Pogonyshev
Guido van Rossum wrote: > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > Additionally consider something like > > > > something.set_callback (x) > > > > Assume that set_callback() wants to check if `x' is callable at > > all, to raise exception early and make error tracking easie

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Guido van Rossum
On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > What if someone passes a callable that doesn't have the expected signature? > > Well, I don't know a way to catch such situations now, so removing > callable() will not make it worse (even if you don't know about ha

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Alexey Borzenkov
On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > assert hasattr(x, '__call__') > > > > I note that callable() was introduced before all callable objects had > > a __call__ attribute. This is no longer the case, so it's not needed. > I just didn't think about that possibility. If that work

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Alexey Borzenkov
On 4/8/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > What if someone passes a callable that doesn't have the expected > > > signature? > > Well, I don't know a way to catch such situations now, so removing

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Paul Pogonyshev
Guido van Rossum wrote: > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > What if someone passes a callable that doesn't have the expected > > > signature? > > > > Well, I don't know a way to catch such situations now, so removing > > callable() will not mak

Re: [Python-Dev] Extended buffer PEP

2007-04-08 Thread Travis Oliphant
Carl Banks wrote: > Only one concern: > > > typedef int (*getbufferproc)(PyObject *obj, struct bufferinfo > *view) > > > I'd like to see it accept a flags argument over what kind of buffer > it's allowed to return. I'd rather not burden the user to check all > the entries in bufferinfo to m

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > What if someone passes a callable that doesn't have the expected > > > signature? > > > > Well, I don't know a way to catch such situations now, so removing > >

Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Steven Bethard
A summary response to the issues raised so far... On what the name should be: * Adam Olsen - countunique(), countdistinct(), countduplicates() * Greg Ewing - counteach(), countall() * Kevin Jacobs - tally() * Guido - counts() is fine So I guess I'll stick with counts(). On whether the count of a

Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Georg Brandl
Steven Bethard schrieb: > A summary response to the issues raised so far... > > On what the name should be: > * Adam Olsen - countunique(), countdistinct(), countduplicates() > * Greg Ewing - counteach(), countall() > * Kevin Jacobs - tally() > * Guido - counts() is fine > So I guess I'll stick wi

Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Guido van Rossum
On 4/8/07, Georg Brandl <[EMAIL PROTECTED]> wrote: > I can live with counts(), though I always ask myself "who counts?" ;) The Count, of course. :-) -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-D

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Phillip J. Eby
At 08:01 PM 4/8/2007 +0400, Alexey Borzenkov wrote: >On 4/8/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > > Guido van Rossum wrote: > > > > What if someone passes a callable that doesn't have the expected > signature? > > > Well, I do

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread Guido van Rossum
On 4/8/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > > > Guido van Rossum wrote: > > > > What if someone passes a callable that doesn't have the expected > > > > signature? > > > > > > Well,

Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Greg Ewing
Raymond Hettinger wrote: > Instead of a separate function in collections, it may be sensible to stick > with > the familiar and provide a dictionary contructor for the commonly encounter > use > case of counting things: I don't think that's a good idea. The dict class should restrict itself to b

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread BJörn Lindqvist
On 4/8/07, Paul Pogonyshev <[EMAIL PROTECTED]> wrote: > I have no problems with Python being untyped. But I want that error > stack traces provide some useful information as possible with reasonable > effort and that errors happen as early as possible. In particular, stack > trace should mention

Re: [Python-Dev] Extended buffer PEP

2007-04-08 Thread Greg Ewing
Travis Oliphant wrote: > Carl Banks wrote: > > I'd like to see it accept a flags argument over what kind of buffer > > it's allowed to return. I'd rather not burden the user to check all > > the entries in bufferinfo to make sure it doesn't get something > > unexpected. > Yes, I agree. We had s

Re: [Python-Dev] function for counting items in a sequence

2007-04-08 Thread Greg Ewing
Steven Bethard wrote: > * Greg Ewing - counteach(), countall() > * Guido - counts() is fine I'm happy with counts() too -- I only suggested the others in case counts() wasn't acceptable for some reason. If Guido likes it, that's good enough for me. -- Greg ___

Re: [Python-Dev] concerns regarding callable() method

2007-04-08 Thread skip
Guido> My point is that it's futile to use callable() -- even if it Guido> passes, you have no assurance that you actually have a valid Guido> callback. So why bother with it at all? It's counter to the Guido> spirit of Python. If someone passes you a bad callback, they will Gu

[Python-Dev] Weekly Python Patch/Bug Summary

2007-04-08 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 349 open ( +7) / 3737 closed (+25) / 4086 total (+32) Bugs: 939 open (-12) / 6648 closed (+60) / 7587 total (+48) RFE : 249 open ( -8) / 278 closed (+12) / 527 total ( +4) New / Reopened Patches __ Python 2.