|
![](/i/fill.gif) |
On 10/16/2012 5:06, Warp wrote:
> Well, for one, methods taking 'self' as a parameter seems highly unusual
A function that takes "self" as the first argument is a method. Otherwise
it's a function.
> Using __ as a syntax to denote a special meaning of functions and variables
> is also quite unusual,
The constructor is named __init__
The operator+ method is named __add__
And so on. It just avoids special syntax and substitutes special names.
The variable __y is just a plain old variable with the name mangled for
pseudoreadability, exactly like naming a member variable in C++ m_xyz so you
remember it's a member variable when you use it. Personally, I never saw the
point. But since Python doesn't have "private" vs "public" variables, people
have taken to using leading underscores to mean "don't touch this from outside."
> Programming
> languages seldom give any special syntactic meaning to variables and
> function names containing underscores. (Instead, they usually use actual
> keywords to express, for example, member variable visibility.)
Unless it, say, a destructor in C++ ;-)
Honestly, I always thought naming the constructor after the class was a
terrible decision.
> very beginning of Python, I must say that it's... unusual, to put it in
> nice terms.
It *is* unusual. It's not especially broken.
--
Darren New, San Diego CA, USA (PST)
"They're the 1-800-#-GORILA of the telecom business."
Post a reply to this message
|
![](/i/fill.gif) |