Re: Candidate for a new itertool

2009-03-18 Thread Aahz
In article 6ca71455-2fb2-4dd0-a500-2a480d815...@v6g2000vbb.googlegroups.com, Raymond Hettinger pyt...@rcn.com wrote: For edge-triggered events, we need to convert a boundary-event predicate to groupby-style key function. The code below encapsulates that process in a new itertool called

Re: Candidate for a new itertool

2009-03-18 Thread George Sakkis
On Mar 7, 8:47 pm, Raymond Hettinger pyt...@rcn.com wrote: The existing groupby() itertool works great when every element in a group has the same key, but it is not so handy when groups are determined by boundary conditions. For edge-triggered events, we need to convert a boundary-event

Re: Candidate for a new itertool

2009-03-12 Thread pruebauno
On Mar 7, 8:47 pm, Raymond Hettinger pyt...@rcn.com wrote: The existing groupby() itertool works great when every element in a group has the same key, but it is not so handy when groups are determined by boundary conditions. For edge-triggered events, we need to convert a boundary-event

Re: Candidate for a new itertool

2009-03-10 Thread pruebauno
On Mar 9, 6:55 pm, Raymond Hettinger pyt...@rcn.com wrote: [prueba] The data often contains objects with attributes instead of tuples, and I expect the new namedtuple datatype to be used also as elements of the list to be processed. But I haven't found a nice generalized way for that

Re: Candidate for a new itertool

2009-03-09 Thread Raymond Hettinger
On Mar 7, 7:58 pm, bearophileh...@lycos.com wrote: Raymond Hettinger, maybe it can be useful to add an optional argument flag to tell such split_on to keep the separators or not? This is the xsplit I usually use: In your experiences with xsplit(), do most use cases involve removing the

Re: Candidate for a new itertool

2009-03-09 Thread bearophileHUGS
Raymond Hettinger: In your experiences with xsplit(), do most use cases involve removing the separators? Unfortunately I am not able to tell you how often I remove them. But regarding strings, I usually want to remove separators: aXcdXfg.split(X) ['a', 'cd', 'fg'] So sometimes I want to do

Re: Candidate for a new itertool

2009-03-09 Thread pruebauno
On Mar 7, 8:47 pm, Raymond Hettinger pyt...@rcn.com wrote: The existing groupby() itertool works great when every element in a group has the same key, but it is not so handy when groups are determined by boundary conditions. For edge-triggered events, we need to convert a boundary-event

Re: Candidate for a new itertool

2009-03-09 Thread Raymond Hettinger
[prueba] The data often contains objects with attributes instead of tuples, and I expect the new namedtuple datatype to be used also as elements of the list to be processed. But I haven't found a nice generalized way for that kind of pattern that aggregates from a list of one datatype to a

Re: Candidate for a new itertool

2009-03-08 Thread jay logan
On Mar 7, 8:47 pm, Raymond Hettinger pyt...@rcn.com wrote: The existing groupby() itertool works great when every element in a group has the same key, but it is not so handy when groups are determined by boundary conditions. For edge-triggered events, we need to convert a boundary-event

Candidate for a new itertool

2009-03-07 Thread Raymond Hettinger
The existing groupby() itertool works great when every element in a group has the same key, but it is not so handy when groups are determined by boundary conditions. For edge-triggered events, we need to convert a boundary-event predicate to groupby-style key function. The code below

Re: Candidate for a new itertool

2009-03-07 Thread bearophileHUGS
Raymond Hettinger, maybe it can be useful to add an optional argument flag to tell such split_on to keep the separators or not? This is the xsplit I usually use: def xsplit(seq, key=bool, keepkeys=True): xsplit(seq, key=bool, keepkeys=True): given an iterable seq and a predicate key,