On Apr 17, 12:07 pm, Sion Arrowsmith <[EMAIL PROTECTED]>
wrote:
>  <[EMAIL PROTECTED]> wrote:
> >In Python, you usually can use parentheses to split something over
> >several lines. But you can't use parentheses for an assignment of
> >several lines.
>
> Yes you can, you just need an iterable of the right length on
> the other side for the tuple unpacking to work:
>
> >>> (CONSTANT1,
>
> ... # This isn't a syntax error
> ...  CONSTANT2,
> ...  CONSTANT3, #and neither is this
> ...  CONSTANT) = [1] * 4>>> [ (k, v) for k, v in locals().items() if 
> k.startswith("CONSTANT") ]
>
> [('CONSTANT', 1), ('CONSTANT1', 1), ('CONSTANT3', 1), ('CONSTANT2', 1)]
>

That's not the same kind of multiple assignment. There, you're just
unpacking several items from a sequence into several variables on the
left. Some would say that's a list assignment.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to