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 bac
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
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
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
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 cl
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):
>
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:
[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),
>
[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 occur
[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 whil
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 function
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.
--
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
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 dropwhi
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 ver
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.
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 creati
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
18 matches
Mail list logo