Interesting behaviour of the assignment

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Jan 1 08:21:29 EST 2001


"Tim Peters" <tim.one at home.com> writes:

> Now "is" is bulletproof.  A stranger way:
> 
> SPAM = []
> EGGS = []

First I thought: wow, that must be the shortest way to create
"enumerated" objects. But then I noticed a flaw: SPAM == EGGS.  So I
still like the FoodType class approach best, although this restriction
can be worked around with

SPAM = []
EGGS = [SPAM]
WHAT_COMES_NEXT = [EGGS]

Regards,
Martin



More information about the Python-list mailing list