automatically mapping builtins (WAS: itertools to iter transition)
mahs at telcopartners.com
Wed Mar 30 05:23:12 CEST 2005
Steven Bethard wrote:
> Michael Spencer wrote:
> > While we're on the topic, what do you think of having unary,
> > non-summary builtins automatically map themselves when called with an
> > iterable that would otherwise be an illegal argument:
> I personally don't much like the idea because I expect 'int' to produce
> an int, just like I expect 'list' to produce a list. So having 'int'
> produce an iterable in any situation seems inappropriate to me.
Bengt Richter wrote:
> That last "otherwise" is pretty important for strings as in int('1234') ;-)
> But wouldn't you really currently write the "->" form from above? I.e.,
> for ordchar in (ord(c) for c in somestring):
Thanks for the reactions, (and test implementation, Bengt)
Something to play with, but the idea doesn't seem like a big win, when the
explicit genexp is fully general and only slightly more verbose.
More information about the Python-list