Steven D'Aprano wrote:
[...]
[tongue firmly in cheek]
Perhaps what we need is a more flexible enumerate function?
enumerate(iterable, start_at_index=0, count_from=0)
Super idea. Then we can have a thread about whether it belongs in
itertools or somewhere else.
[...]
Please take your tongue ou
Greg Ewing wrote:
Steven D'Aprano wrote:
With iterators being such a fundamental part of Python these days,
perhaps one day we'll see the functions in the itertools module become
iterator methods
I hope not. The set of potential functions that operate
on iterators is open-ended, and there's n
Steven D'Aprano wrote:
With iterators being such a fundamental part of Python these days,
perhaps one day we'll see the functions in the itertools module become
iterator methods
I hope not. The set of potential functions that operate
on iterators is open-ended, and there's no reason to
single
On Tue, May 13, 2008 at 3:11 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> With iterators being such a fundamental part of Python these days,
> perhaps one day we'll see the functions in the itertools module become
> iterator methods, as happened with strings. But that's a discussion for
> a
On Wed, 14 May 2008 05:01:20 am you wrote:
> > While slices are wonderfully useful things, they aren't panaceas.
> > They're not so useful with iterators, and they make a copy of the
> > data, which can be problematic if there's a *lot* of it.
>
> That's why we have itertools.islice().
I always
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|
| If you are generating paginated output then a function to generate an
| arbitrary page would likely want to enumerate starting at some value
larger
| than one.
|
| Of course in that case you'll also want to skip part
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Greg Ewing wrote:
| Steven D'Aprano wrote:
|> The only thing I can think of is printing lines with line numbers
|
| Parsing a file and wanting to be able to print
| error messages with line numbers would seem to
| be a fairly likely use.
What is wron
Guido van Rossum schrieb:
On Tue, May 13, 2008 at 11:59 AM, Facundo Batista
<[EMAIL PROTECTED]> wrote:
2008/5/13, Steven D'Aprano <[EMAIL PROTECTED]>:
> Perhaps what we need is a more flexible enumerate function?
> enumerate(iterable, start_at_index=0, count_from=0)
+1 to provide both op
On Tue, May 13, 2008 at 11:59 AM, Facundo Batista
<[EMAIL PROTECTED]> wrote:
> 2008/5/13, Steven D'Aprano <[EMAIL PROTECTED]>:
>
>
> > Perhaps what we need is a more flexible enumerate function?
> > enumerate(iterable, start_at_index=0, count_from=0)
>
> +1 to provide both options: they're not
On Tue, May 13, 2008 at 11:53 AM, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Wed, 14 May 2008 12:25:01 am Guido van Rossum wrote:
>
> > However I see no use for skipping items
> > from the start,
>
> You've never had to deal with data where the first N items were special
> in some way? e.g
2008/5/13, Steven D'Aprano <[EMAIL PROTECTED]>:
> Perhaps what we need is a more flexible enumerate function?
> enumerate(iterable, start_at_index=0, count_from=0)
+1 to provide both options: they're not intrusive (as I can keep using
enumerate without those), and having both helps in the under
On Wed, 14 May 2008 12:25:01 am Guido van Rossum wrote:
> However I see no use for skipping items
> from the start,
You've never had to deal with data where the first N items were special
in some way? e.g. skipping over a header line in a file?
I know I've written code like this before:
it =
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
> On Mon, 12 May 2008 08:20:51 am Georg Brandl wrote:
>> I believe the following is a common use-case for enumerate()
>> (at least, I've used it quite some times):
>>
>> for lineno, line in enumerate(fileobject):
>> ...
>>
>> For this, it would be
On Tue, May 13, 2008 at 2:40 AM, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> Terry Reedy wrote:
>>
>> "Nick Coghlan" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> | I'd like to hear from Raymond before we do this. I'm pretty sure we had
>> | a reason for *not* doing it that way in
Terry Reedy wrote:
"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| I'd like to hear from Raymond before we do this. I'm pretty sure we had
| a reason for *not* doing it that way in when enumerate() was added, but
| I can't remember what that reason might have been...
"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| I'd like to hear from Raymond before we do this. I'm pretty sure we had
| a reason for *not* doing it that way in when enumerate() was added, but
| I can't remember what that reason might have been...
http://bugs.python
Georg Brandl wrote:
I believe the following is a common use-case for enumerate()
(at least, I've used it quite some times):
for lineno, line in enumerate(fileobject):
...
For this, it would be nice to have a start parameter for enumerate().
The changes are minimal -- okay for 2.6?
I'd lik
Steven D'Aprano wrote:
On Mon, 12 May 2008 08:20:51 am Georg Brandl wrote:
I believe the following is a common use-case for enumerate()
(at least, I've used it quite some times):
for lineno, line in enumerate(fileobject):
...
For this, it would be nice to have a start parameter for enumer
Brett Cannon wrote:
Sure, making it 'start' or something and having it be keyword-only makes sense.
http://bugs.python.org/issue2831
-Scott
--
Scott Dial
[EMAIL PROTECTED]
[EMAIL PROTECTED]
___
Python-Dev mailing list
Python-Dev@python.org
http://ma
On Mon, May 12, 2008 at 12:21:00PM +1200, Greg Ewing wrote:
> Parsing a file and wanting to be able to print
> error messages with line numbers would seem to
> be a fairly likely use.
Couldn't people be using the fileinput module for this, though?
--amk
___
On Sun, May 11, 2008 at 6:23 PM, Scott Dial
<[EMAIL PROTECTED]> wrote:
> Brett Cannon wrote:
>>
>> Taking a new argument that has a default shouldn't be an issue. +1
>> from me. I assume it is just going to start the count at that number,
>> not advance the iterable to that point, right?
>
> I wond
+1 to this.
On Sun, May 11, 2008 at 6:23 PM, Scott Dial
<[EMAIL PROTECTED]> wrote:
> Brett Cannon wrote:
>>
>> Taking a new argument that has a default shouldn't be an issue. +1
>> from me. I assume it is just going to start the count at that number,
>> not advance the iterable to that point, righ
Brett Cannon wrote:
Taking a new argument that has a default shouldn't be an issue. +1
from me. I assume it is just going to start the count at that number,
not advance the iterable to that point, right?
I wonder if it would be best for it to be a keyword-only argument. So
many of the utility f
Steven D'Aprano wrote:
The only thing I can think of is printing lines with line numbers
Parsing a file and wanting to be able to print
error messages with line numbers would seem to
be a fairly likely use.
--
Greg
___
Python-Dev mailing list
Python-
2008/5/11, Brett Cannon <[EMAIL PROTECTED]>:
> It's a common enough use-case, so I think it makes sense. With the
> cost being so minimal to add support I think this one use-case alone
> is enough to justify adding the support.
+1
--
.Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr
On Sun, May 11, 2008 at 4:42 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Mon, 12 May 2008 08:20:51 am Georg Brandl wrote:
>> I believe the following is a common use-case for enumerate()
>> (at least, I've used it quite some times):
>>
>> for lineno, line in enumerate(fileobject):
>> ..
On Mon, 12 May 2008 08:20:51 am Georg Brandl wrote:
> I believe the following is a common use-case for enumerate()
> (at least, I've used it quite some times):
>
> for lineno, line in enumerate(fileobject):
> ...
>
> For this, it would be nice to have a start parameter for enumerate().
Why wo
Brett Cannon schrieb:
On Sun, May 11, 2008 at 3:20 PM, Georg Brandl <[EMAIL PROTECTED]> wrote:
I believe the following is a common use-case for enumerate()
(at least, I've used it quite some times):
for lineno, line in enumerate(fileobject):
...
For this, it would be nice to have a start pa
On Sun, May 11, 2008 at 3:20 PM, Georg Brandl <[EMAIL PROTECTED]> wrote:
> I believe the following is a common use-case for enumerate()
> (at least, I've used it quite some times):
>
> for lineno, line in enumerate(fileobject):
>...
>
> For this, it would be nice to have a start parameter for e
I believe the following is a common use-case for enumerate()
(at least, I've used it quite some times):
for lineno, line in enumerate(fileobject):
...
For this, it would be nice to have a start parameter for enumerate().
The changes are minimal -- okay for 2.6?
Georg
--
Thus spake the Lord
30 matches
Mail list logo