Am I the only one who would love these extentions? - Python 3.0 proposals (long)

Alexander Schmolck a.schmolck at gmx.net
Tue Nov 11 04:30:00 EST 2003


"Andrew Dalke" <adalke at mindspring.com> writes:

> Just to highlight a new suggestion I made that I hadn't seen before,
> use eillipsis ("...") at the end of a list assignment to mean "ignore the
> rest of
> the RHS."  This would allow a style of enum definition like
> 
>  class Keywords:
>    AND, ASSERT, BREAK, CLASS, CONTINUE, DEF,  \
>      DEL, ELIF, YIELD, ...  = itertools.count()

IMHO, this is a not such a good way to define enums. Why not do

AND, ASSERT, BREAK, CLASS, etc == "AND, ASSERT, BREAK, CLASS, etc".split(", ")

This is almost as easy to type (or rather paste) and you shouldn't loose
comparison efficiency as long as you compare with 'is':

  ``if thingy is CLASS: blah``

and you've got the significant advantage that screw-ups are less likely and
you automatically get sensible print values. If you need equality comparisons
often maybe ``map(intern,...`` would help, but I don't know about that.

Nonetheless I think would really like see something along those lines because
I think there a plenty other good uses (especially, as you suggest in
combination with iterators).I'd also like to have the apply-* work in
assignments, e.g. ``first, second, *rest = someList``. This would also make
python's list destructuring facilities much more powerful.

'as




More information about the Python-list mailing list