Re: [Tutor] Copying a mutable

2011-06-07 Thread Válas Péter
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

Re: [Tutor] Copying a mutable

2011-06-07 Thread Dave Angel
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

Re: [Tutor] Copying a mutable

2011-06-07 Thread Nathan
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

Re: [Tutor] Copying a mutable

2011-06-07 Thread 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 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]

Re: [Tutor] Copying a mutable

2011-06-07 Thread Válas Péter
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 -

Re: [Tutor] Copying a mutable

2011-06-07 Thread Wayne Werner
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'

Re: [Tutor] if statement

2011-06-07 Thread Alan Gauld
"Andre Engels" wrote Actually, no, this case it's not your ignorance. What is probably going on is that you are using Python 2, but the book is going with Python 3. You can quickly check the version by just typing python at an OS command prompt to get into the interactive interpreter(>>>)

[Tutor] Copying a mutable

2011-06-07 Thread 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). How is that, what is the explanation? Meanwhile the same for immutable types results a real copy, and so does for simple mutables such

Re: [Tutor] if statement

2011-06-07 Thread Andre Engels
On Tue, Jun 7, 2011 at 11:26 PM, Matthew Brunt wrote: > i'm very new to python (currently going through a python for beginners > book at work to pass the time), and i'm having trouble with an if > statement exercise.  basically, i'm creating a very simple password > program that displays "Access G

[Tutor] if statement

2011-06-07 Thread Matthew Brunt
i'm very new to python (currently going through a python for beginners book at work to pass the time), and i'm having trouble with an if statement exercise. basically, i'm creating a very simple password program that displays "Access Granted" if the if statement is true. the problem i'm having is

Re: [Tutor] floats

2011-06-07 Thread Walter Prins
Hello Michael On 7 June 2011 21:10, Michael bridges wrote: > ok, will attempt to clarify. > i want to out put of two numbers [int or float or anything] to be x.xx not > x.x. > i want two numbers after the decimal not one. > > Alan's already given you exactly the correct answer. Have you tried h

Re: [Tutor] floats

2011-06-07 Thread Michael bridges
ok, will attempt to clarify. i want to out put of two numbers [int or float or anything] to be x.xx not x.x. i want two numbers after the decimal not one. --- On Tue, 6/7/11, Alan Gauld wrote: > From: Alan Gauld > Subject: Re: [Tutor] floats > To: tutor@python.org > Date: Tuesday, June 7, 2011

Re: [Tutor] floats

2011-06-07 Thread Alan Gauld
"Michael bridges" wrote i want to 10 / 1000 and get 0.01 not 0 if 1000 is made 1000.00 then 0.01 is printed but that gives 500 / 1000.00 is 0.5 not 0.50 can someone till me how to get a two decimal precision every time? You are confusing two different things.. The first case is that of inte