an ingrate newbie complains

Batista, Facundo FBatista at uniFON.com.ar
Wed Feb 4 19:05:04 CET 2004


Elaine Jackson wrote:

#- 1) I find the following behavior puzzling and disappointing:
#- 
#- >>> X=[(1,1),(2,4),(3,9),(4,16),(5,25)]
#- >>> Y=dict(X)
#- >>> Z=list(Y)
#- >>> Z==X
#- False
#- >>> Z==Y.keys()
#- True

>>> Y
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
>>> Z
[1, 2, 3, 4, 5]

I should expect that Z is not equal to Y.

>>> Y.keys()
[1, 2, 3, 4, 5]

And Y.keys() is equal to Z.


 
#- 2) How come you can't write...
#- 
#- if y = f(x) > 3:
#-     <do a bunch of things with x and y>

See the FAQ:

http://www.python.org/doc/faq/general.html#why-can-t-i-use-an-assignment-in-
an-expression

.	Facundo




More information about the Python-list mailing list