Re: [Tutor] classes and the deepcopy function

2008-01-07 Thread Tiger12506
> Hi > > I was trying to learn about classes in Python and have been playing > around but I am having a problem with the deepcopy function. I want to > have a function that returns a clean copy of an object that you can > change without it changing the original, but no matter what I do the > origin

Re: [Tutor] classes and the deepcopy function

2008-01-06 Thread bob gailer
Michael wrote: > Okay > > Just when I think I am getting it you throw this in. You're welcome. > So why does a become local to each variable but b seem global? > A better way to ask that is "why does a become an instance property but b remain a class property?" f.a = 3 This is an assignment

Re: [Tutor] classes and the deepcopy function

2008-01-06 Thread Michael
Okay Just when I think I am getting it you throw this in. So why does a become local to each variable but b seem global? Michael bob gailer wrote: > Michael wrote: >> Hi Michael >> >> Thanks for the quick reply, I think I get it. So becuase I did not >> declare them withing the init method usi

Re: [Tutor] classes and the deepcopy function

2008-01-05 Thread bob gailer
Michael wrote: > Hi Michael > > Thanks for the quick reply, I think I get it. So becuase I did not > declare them withing the init method using self they are shared by every > object that is created, even completely brand new ones? > > Is it normal practice to declare your variables in a class? I

Re: [Tutor] classes and the deepcopy function

2008-01-05 Thread Alan Gauld
"Michael" <[EMAIL PROTECTED]> wrote > Is it normal practice to declare your variables in a class? I notice > that you don't have to, you can create them as you go, but i thought > declaring and initialising them in the class would make it easier to > understand and see what the class is for and s

Re: [Tutor] classes and the deepcopy function

2008-01-04 Thread Michael
Hi Michael Thanks for the quick reply, I think I get it. So becuase I did not declare them withing the init method using self they are shared by every object that is created, even completely brand new ones? Is it normal practice to declare your variables in a class? I notice that you don't hav

[Tutor] classes and the deepcopy function

2008-01-04 Thread Michael H. Goldwasser
Hi Michael, This is a very interesting example. You do indeed have two distinct copies. The interdependence you are observing is because you have defined CLASS-LEVEL variables (akin to static in Java) rather than instance-level variables. This is because of their declaration within th

[Tutor] classes and the deepcopy function

2008-01-04 Thread Michael
Hi I was trying to learn about classes in Python and have been playing around but I am having a problem with the deepcopy function. I want to have a function that returns a clean copy of an object that you can change without it changing the original, but no matter what I do the original change