Paul Rubin wrote:
> Tim Roberts <[EMAIL PROTECTED]> writes:
>
>> I have to say that I have found this to be a surprisingly common need as
>> well. Would this be an appropriate construct to add to itertools?
>>
>
> I'm in favor.
>
I am ecs
Tim Roberts <[EMAIL PROTECTED]> writes:
> I have to say that I have found this to be a surprisingly common need as
> well. Would this be an appropriate construct to add to itertools?
I'm in favor.
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 27 2007, 11:31 pm, Kugutsumen <[EMAIL PROTECTED]> wrote:
> On Dec 27, 7:24 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
>
>
>
> > > "Kugutsumen" == Kugutsumen <[EMAIL PROTECTED]> writes:
>
> > Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>
> > >> On Dec 27, 11:34
> > Also consider this solution from O'Reilly's Python Cookbook (2nd Ed.) p705
>
> > def chop(iterable, length=2):
> > return izip(*(iter(iterable),) * length)
>
> However, chop ignores the remainder of the data in the example.
There is a recipe in the itertools docs which handles the
> > def chop(iterable, length=2):
> > return izip(*(iter(iterable),) * length)
>
> Is this *always* guaranteed by the language to work?
Yes!
Users requested this guarantee, and I agreed. The docs now explicitly
guarantee this behavior.
Raymond
--
http://mail.python.org/mailman/lis
Hi Igor
> "Igor" == Igor V Rafienko <[EMAIL PROTECTED]> writes:
>> Also consider this solution from O'Reilly's Python Cookbook (2nd Ed.)
>> p705
>>
>> def chop(iterable, length=2):
>> return izip(*(iter(iterable),) * length)
Igor> Is this *always* guaranteed by the language to work? Should
[ Terry Jones ]
[ ... ]
> Also consider this solution from O'Reilly's Python Cookbook (2nd Ed.) p705
>
> def chop(iterable, length=2):
> return izip(*(iter(iterable),) * length)
Is this *always* guaranteed by the language to work? Should the
iterator returned by izip() change the i
On Dec 29, 2007 2:18 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:
> Kugutsumen <[EMAIL PROTECTED]> wrote:
> >
> >I am relatively new the python language and I am afraid to be missing
> >some clever construct or built-in way equivalent to my 'chunk'
> >generator below.
>
> I have to say that I have f
Kugutsumen <[EMAIL PROTECTED]> wrote:
>
>I am relatively new the python language and I am afraid to be missing
>some clever construct or built-in way equivalent to my 'chunk'
>generator below.
I have to say that I have found this to be a surprisingly common need as
well. Would this be an appropri
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496958
from itertools import *
def group(lst, n):
"""group([0,3,4,10,2,3], 2) => iterator
Group an iterable into an n-tuples iterable. Incomplete tuples
are padded with Nones e.g.
>>> list(group(range(10), 3))
[(0, 1,
On Dec 27, 7:24 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
> > "Kugutsumen" == Kugutsumen <[EMAIL PROTECTED]> writes:
>
> Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>
> >> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>
> >> > I am relatively new the py
On Dec 27, 7:24 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
> > "Kugutsumen" == Kugutsumen <[EMAIL PROTECTED]> writes:
>
> Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>
> >> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>
> >> > I am relatively new the py
> "Kugutsumen" == Kugutsumen <[EMAIL PROTECTED]> writes:
Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>>
>> > I am relatively new the python language and I am afraid to be missing
>> > some clever construc
On Thu, 27 Dec 2007 03:34:57 -0800, Kugutsumen wrote:
> I am relatively new the python language and I am afraid to be missing
> some clever construct or built-in way equivalent to my 'chunk' generator
> below.
>
> def chunk(size, items):
> """generate N items from a generator."""
[snip code
On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am relatively new the python language and I am afraid to be missing
> > some clever construct or built-in way equivalent to my 'chunk'
> > generator below.
>
> > def c
On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
> I am relatively new the python language and I am afraid to be missing
> some clever construct or built-in way equivalent to my 'chunk'
> generator below.
>
> def chunk(size, items):
> """generate N items from a generator."""
> chu
I am relatively new the python language and I am afraid to be missing
some clever construct or built-in way equivalent to my 'chunk'
generator below.
def chunk(size, items):
"""generate N items from a generator."""
chunk = []
count = 0
while True:
try:
item = it
17 matches
Mail list logo