What about an EXPLICIT naming scheme for built-ins?

Carlos Ribeiro carribeiro at gmail.com
Tue Sep 7 19:42:35 EDT 2004


On Tue, 07 Sep 2004 20:04:57 GMT, Anna Martelli Ravenscroft
<anna at aleax.it> wrote:
> I *guess* I had thought of it, if at all, as something similar to
> int('2') or float(2). They're useful, but only in very limited specific
> cases. I would have expected list('cat') to force a list out of the
> string. Just like int() or float() and, well, that's it. That's as far
> as I would have thought of it as being useful...

Extending your reasoning a little bit, list(anything) smells a
typecast -- something that's used to convert a variable of one type
into a variable of another type. But a generator can't be "typecast"
in my mental model -- it`s not a variable. It is a "program" that
returns a sequence of values that have to be processed somehow. On the
other hand, [x for x in generator()] reads as a description of what is
getting done -- an algorithm of sorts -- and then it comes up as a
natural solution for the problem.

Now I'll admit my ignorance and say that I didn't had the slightest
idea about what do generator expressions meant until now. I just read
the PEP, and it`s neat -- but I havent time to figure out the impact
(remember, I was out of the list over the past year and half :-)

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list