"Thomas Wouters" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Sat, Mar 15, 2008 at 2:58 PM, Terry Reedy <[EMAIL PROTECTED]> 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:
That may be a fact for your patch but not for all possible patches ;-) | >>> a, b = *c | File "<stdin>", line 1 | SyntaxError: can use starred expression only as assignment target | | It needs something to unpack *into*, in the immediate context. Ditto. My main desire is that *iterable have a simple (easily learnable) consistent meaning. (Part of consistency is having it work the same both in and out of function calls). The rule I suggested is 'execute the statement the same *as if* the iterable items had been written in the code as a comma sequence'. In the above, the result would be a tuple. (For targets, the meaning is similar: *x means, in effect, x[0], x[1], etc, with x sized as needed at runtime.) The fact that the '*' would be redundant in some contexts and therefore useless should not necessarily make it syntax error in that context. if bool(e): pass # and if bool(e) is True: pass are both allowed even thought equivalent to 'if e: pass'. _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
