simultaneous assignment

Boris Borcic bborcic at gmail.com
Tue May 2 13:11:17 EDT 2006


John Salerno wrote:
> Is there a way to assign multiple variables to the same value, but so 
> that an identity test still evaluates to False?
> 
> e.g.:
> 
>  >>> w = x = y = z = False
>  >>> w
> False
>  >>> x
> False
>  >>> w == x
> True
>  >>> w is x
> True         # not sure if this is harmful
> 
> The first line above is the only way I know to do it, but it seems to 
> necessarily lead to the true identity test.

 >>> class Foo :
	def __eq__(*blah) : return False

	
 >>> w = x = y = z = Foo()
 >>> w ==  x
False
 >>> w is x
True
 >>>



More information about the Python-list mailing list