Re: Basic inheritance question



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
.



Relevant Pages

  • (patch for Bash) regex(3) splitting/matching
    ... I usually do this in Python. ... 'help array' will give you more info on other options for 'array' ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: Running autogenerated code in another python instance
    ... I've had a look through Programming Python and the Python Cookbook, which have given me ideas, but nothing has gelled yet, so I thought I'd put the question to the community. ... def __init__: ...
    (comp.lang.python)
  • Re: Python Success stories
    ... `Boxed types' or `boxed objects' is a technical term ... Python has the same basic data model as Lisp, Ruby, Smalltalk and many ... contains a reference to value; values can referred to by many variables. ... mentioned above causes a new reference to be stored in VAR, ...
    (comp.lang.python)
  • Re: Replacement for keyword global good idea? (e.g. modulescope or module better?)
    ... (Those who don't understand the difference between "rebinding a name" and "modifying an object" will need to figure out that distinction before they can participate much in a discussion about Python scopes, ... coherent programming framework.If I can modify an out of scope object (ie var list) without saying it's an 'outer' no problem as python looks for it, in fact I should put 'outer' to rebind var to 4 if I refer to 'var' as an outer binding, python can find it if it exists, if it doesn't it can raise an error. ...
    (comp.lang.python)
  • Re: Class Variable Access and Assignment
    ... functions in other languages, but what is the common way of referring to a class variable. ... the <var> defined in the class where a method you define now is implemented, or you might want in the class of the instance object. ... Python searching in the class scope after searching the instance scope, if it wasn't for the problem below... ...
    (comp.lang.python)