Re: Itertools wishlists

2005-03-17 Thread TZOTZIOY
On Thu, 17 Mar 2005 06:09:44 GMT, rumours say that "Raymond Hettinger" <[EMAIL PROTECTED]> might have written: [snip] >> Did I make you believe I cared about the fate of any function judged unworthy >> even for the documentation? > >No. My note was mainly for the benefit of those who had an inte

Re: Itertools wishlists

2005-03-16 Thread Raymond Hettinger
>itertools.window() with n=2 got rejected. Almost all proposed uses had better > >solutions (such as an accumulator variable or fibonacci sequence style logic: > >a, b = b, a+b). Writing it in C afforded only small speed advantage over a > >solution using izip() and tee(). [Christos TZOTZIOY Geo

Re: Itertools wishlists

2005-03-16 Thread TZOTZIOY
On Sun, 13 Mar 2005 06:52:40 GMT, rumours say that "Raymond Hettinger" <[EMAIL PROTECTED]> might have written: [snip of lots of stuff] >itertools.window() with n=2 got rejected. Almost all proposed uses had better >solutions (such as an accumulator variable or fibonacci sequence style logic: >a,

Re: Itertools wishlists

2005-03-14 Thread bearophileHUGS
Thank you for your answers, Raymond Hettinger. >The options also suggest that the abstraction is not as basic or universal as we would hope.< I don't understand, but this is normal. > ll = open("namefile").read().split() > r = partition(map(float, ll), 4) >If you need that to be flattened one

Re: Itertools wishlists

2005-03-14 Thread Ville Vainio
> "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Steven> complex atomicity test). I also have the feeling that any Steven> complicated atomictiy test is more than a simple and-ing Steven> of several tests... Raymond> "Ville Vainio" >> I also have the feeling

Re: Itertools wishlists

2005-03-14 Thread Raymond Hettinger
> Steven> complex atomicity test). I also have the feeling that any > Steven> complicated atomictiy test is more than a simple and-ing > Steven> of several tests... "Ville Vainio" > I also have the feeling that if the atomicity criterion was any more > complex in the API, the proposal

Re: Itertools wishlists

2005-03-14 Thread Ville Vainio
> "Steven" == Steven Bethard <[EMAIL PROTECTED]> writes: Steven> complex atomicity test). I also have the feeling that any Steven> complicated atomictiy test is more than a simple and-ing Steven> of several tests... I also have the feeling that if the atomicity criterion was any

Re: Itertools wishlists

2005-03-14 Thread Steven Bethard
Robert Brewer wrote: Steven Bethard wrote: Ville Vainio wrote: A simpler API: def flatten(sequence, atomic_test = lambda o: isinstance(o,basestring)): """ don't recurse into iterables if atomic_test -> True """ Yes, this is also the API I would have suggested. Simple, but flexible enough to han

RE: Itertools wishlists

2005-03-14 Thread Robert Brewer
Steven Bethard wrote: > Ville Vainio wrote: > > A simpler API: > > > > def flatten(sequence, atomic_test = lambda o: > isinstance(o,basestring)): > > """ don't recurse into iterables if atomic_test -> True """ > > Yes, this is also the API I would have suggested. Simple, > but flexible enoug

Re: Itertools wishlists

2005-03-14 Thread Steven Bethard
Ville Vainio wrote: A simpler API: def flatten(sequence, atomic_test = lambda o: isinstance(o,basestring)): """ don't recurse into iterables if atomic_test -> True """ Yes, this is also the API I would have suggested. Simple, but flexible enough to handle the odd cases with the occasional user-

Re: Itertools wishlists

2005-03-14 Thread Ville Vainio
> "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Raymond> Each one of the options listed is a reason that flatten() Raymond> shouldn't be an itertool. It fails tests of obviousness, Raymond> learnability, complexity of implementation, and Raymond> simplicity of API

Re: Itertools wishlists

2005-03-13 Thread Raymond Hettinger
[bearophile] > This was my suggestion for a possible flatten(): > > flatten(sequence, level=-1, tuples=True, strings=False, safe=False) > - tuples=True then it flattens tuples too. > - strings=True then it flattens strings with len(s)>1 too. > - safe if True it cheeks (with something like an iterat

Re: Itertools wishlists

2005-03-13 Thread Terry Reedy
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > FWIW, requests for additions to the itertools module have not fallen on > deaf > ears. There are no arbitrary restraints on building out this module. > Each > request has gotten careful thought and a couple of th

Re: Itertools wishlists

2005-03-13 Thread bearophileHUGS
Thank you for your very good and interesting answer Raymond. In the Itertool library there are functions not really simple to use/remember, but a flatten() and a partition() can probably be easy to remember (your window() function is probably a sliding window, so it's not a partition(), I presume).

Re: Itertools wishlists

2005-03-12 Thread Raymond Hettinger
[Ville Vainio] > >For quick-and-dirty stuff, it's often convenient to flatten a sequence > >(which perl does, surprise surprise, by default): . . . > >but something like this would be handy in itertools as well. > > > >It seems trivial, but I managed to screw up several times when trying > >to pro