itertools comments [Was: Re: RELEASED: Python 2.3a2]

Alex Martelli aleax at aleax.it
Fri Feb 21 08:47:24 EST 2003


Paul Rubin wrote:

> "Raymond Hettinger" <vze4rx4y at verizon.net> writes:
>> > Wouldn't `xfilter`, `xmap` etc. be a better naming convention than
>> > `ifilter`, `imap` etc?
>> 
>> There were a number of possible naming styles and, in the end,
>> it is the module writer's perogative.
>> 
>> The i-prefix is supposed to be a reminder that the functions return
>> iterators.  It has a nice, snappy feel to it and is unapologetic about
>> any resemblance to names used in Apple/MacIntosh marketing.
> 
> imap is also an email transfer protocol.  A python program I'm hacking
> on now has an imap class that implementst that protocol.  I guess I'll
> have to rename it.

No need, thanks to namespaces (a honkin' great idea).  itertools.imap
indicates one thing, yourmodule.imap indicates a completely different
one, and you both live happily ever after.  I _would_ suggest adhering
to the convention that class names are capitalized, but that's got
nothing to do with "nameclashes".


> I think xrange, etc. are already a convention for the closest thing
> Python has traditionally had to iterators.  Maybe those functions
> should just be updated to make ordinary iterators.

Not without breaking, e.g., xrange(23, 17923, 12)[15] -- which now
has a perfectly good result of 203 and would break if xrange
returned an iterator (or any other non-indexable object).


Alex





More information about the Python-list mailing list