"Válas Péter" wrote
> really care if the two names are bound to same object, or just to
> two
> objects that happen to have the same value.
Being one of the purposes of Python to be a simple educational
language, I
want to make this simple to a beginner who does care. :-)
That's good. Bu
2011/6/8 Válas Péter
> As far as I understand, assignment means giving a value to a variable which
> is the expression used by classical languages that have variables (such as
> Pascal or Basic). Python has no variables, since even the simpliest data is
> an object, but we still say assignment, b
I think this is easily seen by a for loop:
for something in range(20):
print something
In the above "something" is a variable, in this case an int(which is
immutable). However, "something" is changed every time it goes through the
loop.
It's the equivalent of:
x = 0
x = 1
x = 2
and so on
Just
Válas Péter wrote:
Being one of the purposes of Python to be a simple educational language, I
want to make this simple to a beginner who does care. :-)
Here is a piece of code, Python 3.1.2, a small game with a list and a tuple:
li=[3,4]
id(li)
13711200
la=li
id(la)
13711200
You can make
Walter and Dave, thank you for the useful and detailed answer, now I see it
better. I didn't write code, because once I realized I had spoiled
something, the mistake has no more importance except historical, the correct
solutions have importance.
2011. június 8. 4:19 Dave Angel írta, :
> Now, if
On 01/-10/-28163 02:59 PM, Válas Péter wrote:
Hi,
let X be a mutable container, such as dict/set/list=bytearray, and Y=X,
When I change X, Y will follow it, having always the same value, although
id(X)!=id(Y). How is that, what is the explanation? Meanwhile the same for
immutable types results a
unsubscribe
在 2011-06-08 07:11:33,"Walter Prins" 写道:
Hi,
2011/6/7 Válas Péter
Hi,
let X be a mutable container, such as dict/set/list=bytearray, and Y=X,
When I change X, Y will follow it, having always the same value, although
id(X)!=id(Y).
That's not correct:
Python 2.7 (r27:82525, Jul
Hi,
2011/6/7 Válas Péter
> Hi,
>
> let X be a mutable container, such as dict/set/list=bytearray, and Y=X,
> When I change X, Y will follow it, having always the same value, although
> id(X)!=id(Y).
That's not correct:
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
2011. június 8. 1:02 Wayne Werner írta, :
> You are slightly confused - ints are not mutable!
>
All right, I was really wrong in this question (here it is after midnight
:-), but this doesn't make an influence on the main question.
___
Tutor maillist -
Apologies for the top post, my phone doesn't allow editing the message body.
You are slightly confused - ints are not mutable! You can combine or
multiply them, along with several other operations, but they are certainly
not mutable. The easiest way to check is use them as keys in a dict. You
can'
Hi,
let X be a mutable container, such as dict/set/list=bytearray, and Y=X,
When I change X, Y will follow it, having always the same value, although
id(X)!=id(Y). How is that, what is the explanation? Meanwhile the same for
immutable types results a real copy, and so does for simple mutables such
11 matches
Mail list logo