Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-02-18 Thread Simon Brunning
On Dec 29, 2007 11:10 PM, Raymond Hettinger [EMAIL PROTECTED] wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. Personally, I'd rather you kept them around. I have no FP

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-01-10 Thread Paul Rubin
Raymond Hettinger [EMAIL PROTECTED] writes: I presume you did scans of large code bases and you did not find occurrences of takewhile and dropwhile, right? Yes. I think I have used them. I don't remember exactly how. Probably something that could have been done more generally with

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-01-03 Thread [EMAIL PROTECTED]
On Dec 29 2007, 11:10 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. Well I have just this minute used dropwhile in anger, to find the

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-01-03 Thread Arnaud Delobelle
On Jan 3, 4:39 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Dec 29 2007, 11:10 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming.

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Marc 'BlackJack' Rintsch
On Sat, 29 Dec 2007 15:10:24 -0800, Raymond Hettinger wrote: These thoughts reflect my own experience with the itertools module. It may be that your experience with them has been different. Please let me know what you think. I seem to be in a minority here as I use both functions from time

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Istvan Albert
On Dec 30, 3:29 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: One recipe is extracting blocks from text files that are delimited by a special start and end line. Neat solution! I actually need such functionality every once in a while. Takewhile + dropwhile to the rescue! i. --

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread George Sakkis
On Dec 30, 4:12 pm, Istvan Albert [EMAIL PROTECTED] wrote: On Dec 30, 3:29 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: One recipe is extracting blocks from text files that are delimited by a special start and end line. Neat solution! I actually need such functionality every

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Raymond Hettinger
[bearophile] Here are my usages (every sub-list is sorted by inverted frequency usage): I use often or very often: groupby( iterable[, key]) imap( function, *iterables) izip( *iterables) ifilter( predicate, iterable) islice( iterable, [start,] stop [, step]) I use once in while: cycle(

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Raymond Hettinger
[Michele Simionato] in my code base I have exactly zero occurrences of takewhile and dropwhile, even if I tend to use the itertools quite often. That should be telling. Thanks for the additional empirical evidence. I presume you did scans of large code bases and you did not find

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Raymond Hettinger
[Marc 'BlackJack' Rintsch] I use both functions from time to time. One recipe is extracting blocks from text files that are delimited by a special start and end line. def iter_block(lines, start_marker, end_marker):     return takewhile(lambda x: not x.startswith(end_marker),                

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Raymond Hettinger
FWIW, here is an generator version written without the state flag: def iter_block(lines, start_marker, end_marker): lines = iter(lines) for line in lines: if line.startswith(start_marker): yield line break for line in lines:

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Paul Hankin
On Dec 31, 1:25 am, Raymond Hettinger [EMAIL PROTECTED] wrote: FWIW, here is an generator version written without the state flag:     def iter_block(lines, start_marker, end_marker):         lines = iter(lines)         for line in lines:             if line.startswith(start_marker):        

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Matt Nordhoff
Raymond Hettinger wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. * I'm concerned that use cases for the two functions are uncommon and can obscure code rather than clarify

Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread Raymond Hettinger
I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. * I'm concerned that use cases for the two functions are uncommon and can obscure code rather than clarify it. * I originally added them

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread Istvan Albert
On Dec 29, 6:10 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: These thoughts reflect my own experience with the itertools module. It may be that your experience with them has been different. Please let me know what you think. first off, the itertools module is amazing, thanks for creating

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread Steven D'Aprano
On Sat, 29 Dec 2007 15:10:24 -0800, Raymond Hettinger wrote: * Both functions seem simple and basic until you try to explain them to someone else. Oh I don't know about that. The doc strings seem to do an admirable job to me. Compared to groupby(), the functions are simplicity themselves.

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread bearophileHUGS
Almost every day I write code that uses itertools, so I find it very useful, and its functions fast. Removing useless things and keeping things tidy is often positive. But I can't tell you what to remove. Here are my usages (every sub-list is sorted by inverted frequency usage): I use often or

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread Michele Simionato
On Dec 30, 12:10 am, Raymond Hettinger [EMAIL PROTECTED] wrote: I'm considering deprecating these two functions and would like some feedback from the community or from people who have a background in functional programming. I am with Steven D'Aprano when he says that takewhile and dropwhile