Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-12 Thread Steve Holden
[EMAIL PROTECTED] wrote: [...] > Read my other post. The code was/is definitely identical. In any event, > I don't really care. It's working properly now, and if I have similarly > weird problems in future, I'll deal with them at that time. I don't > know what was up, but I understand it doesn't ma

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-12 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Fredrik Lundh wrote: > >>[EMAIL PROTECTED] wrote: >> >> >>>Output from laptop comp.: >>> >>>1 >>>10 >>>2 >>>10 >>>3 >>>10 >> >>so how are you entering and running the code on your laptop ? >> >>what happens if you set the class attribute to 100 instead of 10 ? >> >> > >

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Diez B. Roggisch wrote: > > No need to be obnoxious. I do appreciate your efforts to help, but you > > must admit, your last statement is a bit snide and certainly not > > useful. > > I'm telling you that the code runs differently on my laptop. > > It certainly doesn't. There is absolutely no ima

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Output from laptop comp.: > > > > 1 > > 10 > > 2 > > 10 > > 3 > > 10 > > so how are you entering and running the code on your laptop ? > > what happens if you set the class attribute to 100 instead of 10 ? > > You can see my other post which

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Oh wow, I wasn't expecting so much help. I really appreciate it. My problem, however, has been solved. I uninstalled my ActiveState Python distro on my laptop and installed the distro from python.org along with Stan's Python Editor. I ran the same code I'd run before and guess what? The behavior no

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Output from laptop comp.: > > 1 > 10 > 2 > 10 > 3 > 10 so how are you entering and running the code on your laptop ? what happens if you set the class attribute to 100 instead of 10 ? -- http://mail.python.org/mailman/listinfo/python-list

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Diez B. Roggisch
> No need to be obnoxious. I do appreciate your efforts to help, but you > must admit, your last statement is a bit snide and certainly not > useful. > I'm telling you that the code runs differently on my laptop. It certainly doesn't. There is absolutely no imaginable way how this behavior could

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Any clue what's behind this behavior? > > a missing plus sign. > > Thanks for the guess but not possible given the following: class Boo: jerk = 10 def killjerk(self): counter = 3 while counter !=0: counte

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Fredrik Lundh
Fredrik Lundh wrote: > a missing plus sign. or a misplaced one... (=+ 1 is not the same thing as += 1) -- http://mail.python.org/mailman/listinfo/python-list

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Any clue what's behind this behavior? a missing plus sign. -- http://mail.python.org/mailman/listinfo/python-list

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Thank you Dennis, this makes the behavior so much clearer to me. I see now that when self.jerk = self.jerk + 1 is executed that even though the names are identical, at this point I'm referring to two different values (one which is being created in part from the other). As for my laptop, I'm not r

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > At first, I thought that self.jerk was resolving to the class attribute > > instead of creating a new variable (w/ a differing scope). > > When you access an instance attribute, Python first looks in the > instance object, and then in the class

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > At first, I thought that self.jerk was resolving to the class attribute > instead of creating a new variable (w/ a differing scope). When you access an instance attribute, Python first looks in the instance object, and then in the class object. When you assign to an i

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Wait a minute! It doesn't explain my bugs. I've got "class variables" acting like instance variables. What's weirder is that this behavior occurs on my computer (in both of my installed WinXP copies) but not on my laptop (WinXP Pro). See the following test: class Boo: jerk = "yes" def ki

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread digitalorganics
Ah, you've brought me much clarity Diez, thank you. That would explain some "bugs" I've been having... Diez B. Roggisch wrote: > [EMAIL PROTECTED] schrieb: > > What's the difference between initializing class variables within the > > class definition directly versus initializing them within the c

Re: direct initialization of class attributes vs. declarations w/in __init__

2006-06-11 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > What's the difference between initializing class variables within the > class definition directly versus initializing them within the class's > __init__ method? Is there a reason, perhaps in certain situations, to > choose one over the other? You are confusing class va