Re: Question on class member in python

2005-10-20 Thread Johnny Lee
It looks like there isn't a last word of the differrences -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on class member in python

2005-10-18 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Johnny Lee <[EMAIL PROTECTED]> wrote: > ... >> Thanks for your help, maybe I should learn how to turn an attibute into >> a property first. > >Easy -- in your class's body, just code: > > def getFoo(self): ... > def setFo

Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote: > Alex Martelli ??? Now that's a peculiar question... > > Johnny Lee <[EMAIL PROTECTED]> wrote: > > > > > But I still wonder what's the difference between the A().getMember and > > > A().member besides the style > > > > Without parentheses after it, getMemb

Re: Question on class member in python

2005-10-18 Thread Christophe
Johnny Lee a écrit : > Alex Martelli 写道: > > >>Johnny Lee <[EMAIL PROTECTED]> wrote: >> >> >>>But I still wonder what's the difference between the A().getMember and >>>A().member besides the style >> >>Without parentheses after it, getMember is a method. The difference >>between a method object

Re: Question on class member in python

2005-10-18 Thread Johnny Lee
Alex Martelli 写道: > Johnny Lee <[EMAIL PROTECTED]> wrote: > > > But I still wonder what's the difference between the A().getMember and > > A().member besides the style > > Without parentheses after it, getMember is a method. The difference > between a method object and an integer object (which i

Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote: > But I still wonder what's the difference between the A().getMember and > A().member besides the style Without parentheses after it, getMember is a method. The difference between a method object and an integer object (which is what member itself is in your

Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote: ... > Thanks for your help, maybe I should learn how to turn an attibute into > a property first. Easy -- in your class's body, just code: def getFoo(self): ... def setFoo(self, value): ... def delFoo(self): ... foo = property(getFoo, setFoo, delFo

Re: Question on class member in python

2005-10-18 Thread Johnny Lee
But I still wonder what's the difference between the A().getMember and A().member besides the style -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on class member in python

2005-10-17 Thread Johnny Lee
Peter Otten 写道: > Johnny Lee wrote: > > > Class A: > >def __init__(self): > > self.member = 1 > > > >def getMember(self): > > return self.member > > > > a = A() > > > > So, is there any difference between a.member and a.getMember? thanks > > for your help. :) > > Yes. accessor

Re: Question on class member in python

2005-10-17 Thread bruno modulix
Johnny Lee wrote: > Class A: s/C/c/ >def __init__(self): > self.member = 1 > >def getMember(self): > return self.member > > a = A() > > So, is there any difference between a.member and a.getMember? yes : a.member is an integer, a.getMember is a bound method. You could hav

Re: Question on class member in python

2005-10-17 Thread Tau
Get answer by typing: id(a.member)==id(a.getMember()) You will often find id() useful when in doubt whether the two objects are distinct. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on class member in python

2005-10-17 Thread Peter Otten
Johnny Lee wrote: > Class A: >def __init__(self): > self.member = 1 > >def getMember(self): > return self.member > > a = A() > > So, is there any difference between a.member and a.getMember? thanks > for your help. :) Yes. accessor methods for simple attributes are a Javais

Question on class member in python

2005-10-17 Thread Johnny Lee
Class A: def __init__(self): self.member = 1 def getMember(self): return self.member a = A() So, is there any difference between a.member and a.getMember? thanks for your help. :) Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list