expression form of one-to-many dict?

Fernando Perez fperez528 at yahoo.com
Tue Dec 21 00:26:52 EST 2004


Doug Holton wrote:

> Mike Meyer wrote:
> 
>> Personally, I'd love a language feature that let you create a function
>> that didn't evaluate arguments until they were actually used - lazy
>> evaluation. That lets you write the C ?: operator as a function, for
>> a start.
>> 
>> Hmmm. No, iterators can't be used to fake it. Oh well.
> 
> That is a brilliant idea.  I would suggest requesting such a feature for
> Python 3.0: http://www.python.org/cgi-bin/moinmoin/Python3.0

Just as a reference, Mathematica does have such a feature, in the form of the
HoldAll, HoldFirst, etc. function attributes.  It can come in quite handy.  I
actually used it to write a little routine to auto-generate python modules for
mathematica variables of certain types, without having to specify a list of
strings for their names.  The evaluation control allowed me to give it a very
clean interface, while the equivalent python2mathematica routine requires a
list of variable names (strings) as input, and plays sys._getframe tricks with
it.  Not very pleasant.

So yes, I think it would be a really nifty feature to have, though I haven't
really thought about how well it meshes (or not) with the rest of python's
design.

Cheers,

f




More information about the Python-list mailing list