[Python-3000] Using *a for packing in lists and other places

Neil Toronto ntoronto at cs.byu.edu
Sun Mar 16 05:51:34 CET 2008


Thomas Wouters wrote:
> 
> On Sat, Mar 15, 2008 at 2:58 PM, Terry Reedy <tjreedy at udel.edu 
> <mailto:tjreedy at udel.edu>> wrote:
> 
>     | Also, yielding everything from an iterator:
>     |
>     | >>> def flatten(iterables):
>     | ...     for it in iterables:
>     | ...         yield *it
> 
>     Following the general rule above for *exp, that would be the same as
>     yield
>     tuple(it).
> 
> No. *exp by itself is not valid syntax:

Why isn't it? I'd rather have one meaning for the *-prefix operator with 
a single special case for assignment targets, than have a bunch of 
special cases scattered across the grammar.

Besides, as the SmugLispWeenies have noted, Python is becoming more like 
Lisp all the time:

     (setq obj '(an ex-parrot))  ; (AN EX-PARROT)
     `(I have ,obj)              ; (I HAVE (AN EX-PARROT))
     `(I have , at obj)             ; (I HAVE AN EX-PARROT)

Why not hasten the transformation? :p

(Only kidding!)

Neil



More information about the Python-3000 mailing list