[Python-bugs-list] [ python-Bugs-476858 ] Assignment to () should be legal (original) (raw)

noreply@sourceforge.net noreply@sourceforge.net
Wed, 31 Oct 2001 10:37:19 -0800


Bugs item #476858, was opened at 2001-10-31 10:07 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476858&group_id=5470

Category: Parser/Compiler Group: None Status: Open Resolution: None Priority: 5 Submitted By: Guido van Rossum (gvanrossum) Assigned to: Nobody/Anonymous (nobody) Summary: Assignment to () should be legal

Initial Comment:

From c.l.py:

Currently,

() = x

gives a compile-time error.

This should really be allowed (and require that x is an empty sequence, of course) as an end case of

(a,b,c) = x  # x must be a 3-sequence
(a,b) = x   # x must be a 2-sequence
(a,) = x    # x must be a 1-sequence
() = x    # why can't x be z 0-sequence?

Comment By: Tim Peters (timone) Date: 2001-10-31 10:37

Message: Logged In: YES user_id=31435

-1. "Assignment statements are used to (re)bind names to values and to modify attributes or items of mutable objects" (from the Ref Man). Since the degenerate cases (don't forget "[] = x" too) don't do that, they're not "assignment statements" in a meanignful sense; they would just be a surprising way to spell

if tuple(x): raise ValueError

That isn't a frequent enough need to deserve special syntax.


You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476858&group_id=5470