Re: Basic inheritance question
- From: Lie <Lie.1296@xxxxxxxxx>
- Date: Mon, 14 Jan 2008 10:15:08 -0800 (PST)
On Jan 7, 2:46 am, Bruno Desthuilliers
<bdesth.quelquech...@xxxxxxxxxxxxxxxxxxx> wrote:
Lie a écrit :
On Jan 5, 5:40 pm, MartinRineh...@xxxxxxxxx wrote:
Jeroen Ruigrok van der Werven wrote:
Shouldn't this be:
self.startLoc = start
self.stopLoc = stop
Thanks! Of course it should. Old Java habits die slowly.
No, seriously it isn't Java habits only, most other languages wouldn't
need explicit calling of class name.
Where is the "explicit calling of class name" exactly ?
Perhaps I was a bit tired when writing that (I wouldn't understand
what I wrote if I were you)... what I meant is most other languages
doesn't usually enforce us to explicitly state the containing class
name, which in python is generally called "self". Most other languages
1) automatically assign the containing class' object in a keyword
(Java: this, VB: Me) behind the screen, and 2) automatically searches
variable name in both the local variable table and the containing
class variable table (so to refer to a class variable named var from a
method inside the class, we only need to write var, not self.var as in
python). In VB, Me is extremely rarely used, in Python, self is all
over the place. Well, there is positive and negative to both sides,
convenience in VB, and flexibility in Python.
Compare the following codes:
VB.NET:
Public Class A
Dim var
Public Function aFunction()
return var
Python:
class A:
def aFunction(self):
return self.var
.
- Follow-Ups:
- Re: Basic inheritance question
- From: Bruno Desthuilliers
- Re: Basic inheritance question
- References:
- Basic inheritance question
- From: MartinRinehart
- Re: Basic inheritance question
- From: Jeroen Ruigrok van der Werven
- Re: Basic inheritance question
- From: MartinRinehart
- Re: Basic inheritance question
- From: Lie
- Re: Basic inheritance question
- From: Bruno Desthuilliers
- Basic inheritance question
- Prev by Date: Re: split parameter line with quotes
- Next by Date: Re: wxpython-wx.CheckListBox: changing item bacgkground color
- Previous by thread: Re: Basic inheritance question
- Next by thread: Re: Basic inheritance question
- Index(es):
Relevant Pages
|