On Fri, Nov 14, 2008 at 6:38 PM, Joe Strout <[EMAIL PROTECTED]> wrote:
> On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote:
>
>> Then add
>> def __init__(self):
>> a = 0
>> b = 0
>
> Doesn't that have to be "self.a" and "self.b"?
Yes, that should indeed have been self.a and self.b! Sorry about that
On Fri, 14 Nov 2008 16:38:15 -0700, Joe Strout wrote:
> On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote:
>
>> Then add
>> def __init__(self):
>> a = 0
>> b = 0
>>
>> to your box class to make a and b instance variables.
>
> Doesn't that have to be "self.a" and "self.b"?
Only if you want it to
BiraRai a écrit :
(snip)
class box:
a = int()
b = int()
I strongly suggest you read the tutorial.
--
http://mail.python.org/mailman/listinfo/python-list
BiraRai a écrit :
for record in roll:
x = box()
x.createSomething(record)
do something
Can anyone tell me why python keeps return the original object x that
was created in the FOR loop.
Where is the "return" statement ?
I want to instantiate a new x object for
each iterat
Jerry Hill a écrit :
On Fri, Nov 14, 2008 at 6:10 PM, BiraRai <[EMAIL PROTECTED]> wrote:
class box:
a = int()
b = int()
def createSomething(self,x):
At a guess, x = box() does create a new instance of your box class,
but since you've declared a and b to be class variables instead of
inst
On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote:
Then add
def __init__(self):
a = 0
b = 0
to your box class to make a and b instance variables.
Doesn't that have to be "self.a" and "self.b"?
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Nov 14, 2008 at 6:10 PM, BiraRai <[EMAIL PROTECTED]> wrote:
> class box:
> a = int()
> b = int()
>
> def createSomething(self,x):
At a guess, x = box() does create a new instance of your box class,
but since you've declared a and b to be class variables instead of
instance variables,
On Nov 14, 5:44 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Nov 14, 5:16 pm, BiraRai <[EMAIL PROTECTED]> wrote:
>
> > for record in roll:
> > x = box()
> > x.createSomething(record)
> > do something
>
> > Can anyone tell me why python keeps return the original object x that
>
On Nov 14, 5:16 pm, BiraRai <[EMAIL PROTECTED]> wrote:
> for record in roll:
> x = box()
> x.createSomething(record)
> do something
>
> Can anyone tell me why python keeps return the original object x that
> was created in the FOR loop. I want to instantiate a new x object for
> e