Fate of itertools.dropwhile() and itertools.takewhile()
winjer at gmail.com
winjer at gmail.com
Thu Jan 3 11:39:36 EST 2008
On Dec 29 2007, 11:10 pm, Raymond Hettinger <pyt... at rcn.com> 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 next
suitable filename when writing database dumps using date.count names:
filename = "%02d-%02d-%d" % (now.day, now.month, now.year)
if os.path.exists(filename):
candidates = ("%s.%d" % (filename, x) for x in count(1))
filename = dropwhile(os.path.exists, candidates).next()
Much clearer than the alternatives I think, please keep dropwhile and
takewhile in itertools ;)
Cheers,
Doug.
More information about the Python-list
mailing list