Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92465 > unrolled thread

I don't like the OO part of python. In particular the "self" keyword everywhere.

Started by"Skybuck Flying" <skybuck2000@hotmail.com>
First post2015-06-11 13:19 +0200
Last post2015-06-11 09:55 -0700
Articles 9 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  I don't like the OO part of python. In particular the "self" keyword everywhere. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-06-11 13:19 +0200
    Re: I don't like the OO part of python. In particular the "self" keyword everywhere. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-06-11 13:27 +0200
      Re: I don't like the OO part of python. In particular the "self" keyword everywhere. Chris Angelico <rosuav@gmail.com> - 2015-06-11 21:36 +1000
      Re: I don't like the OO part of python. In particular the "self" keyword everywhere. Chris Angelico <rosuav@gmail.com> - 2015-06-11 21:38 +1000
      Re: I don't like the OO part of python. In particular the "self" keyword everywhere. MRAB <python@mrabarnett.plus.com> - 2015-06-11 13:16 +0100
        Re: I don't like the OO part of python. In particular the "self" keyword everywhere. Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2015-06-11 17:32 +0200
    Re: I don't like the OO part of python. In particular the "self" keyword everywhere. Michael Torrie <torriem@gmail.com> - 2015-06-11 08:15 -0600
    Re: I don't like the OO part of python. In particular the "self" keyword everywhere. Rustom Mody <rustompmody@gmail.com> - 2015-06-11 09:39 -0700
    Re: I don't like the OO part of python. In particular the "self" keyword everywhere. sohcahtoa82@gmail.com - 2015-06-11 09:55 -0700

#92465 — I don't like the OO part of python. In particular the "self" keyword everywhere.

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-06-11 13:19 +0200
SubjectI don't like the OO part of python. In particular the "self" keyword everywhere.
Message-ID<a91ad$55796ed2$5419aafe$46975@news.ziggo.nl>
Hello,

I don't like the object orientated part of Python.

The idea/prospect of having to write "self" everywhere... seems very 
horrorific and a huge time waster.

(Perhaps the module thing of python might help in future not sure about 
that).

What are your thoughts on the "self" thing/requirement.

I only want replies from expert programmers, cause we need a language for 
expert programmers...

Not noobies that need to be hand-held...

Personally I think I could do just fine with the "self" keyword everywhere.

So question is... can the python interpreter/compiler be written in such a 
way that self can be left out ?

In other words: Is there any hope... that this part of the language will be 
cleaned up some day ?

Are there any tricks to get rid of it ?

Maybe "white" like in Delphi ?

I haven't written much OO code yet in Python... and don't plan on doing it 
too...

Cause it looks hellish confusing... and clouded/clodded.

I think I have better things to do then to insert "self" everywhere...

It's almost like "self" masturbation  LOL.

Bye,
  Skybuck =D 

[toc] | [next] | [standalone]


#92468

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-06-11 13:27 +0200
Message-ID<77496$55797095$5419aafe$48148@news.ziggo.nl>
In reply to#92465
Then again...

I also believe the highest goal for a programming language is "natural 
spoken" language.

If "self.somefield" equals 10 then...

Does have some understandable ring to it.

However... time constraints also have to be kept in mind.

In another words if the code looks like

begin of class section

if somefield equals 10 then...


end of class section

Should be pretty obvious that somefield belongs to class section...

So no need to specify self...

If I wanted to access a global variable I would use the existing "global" 
thing

global SomeField...

maybe if I wanted to use a local variable for routine:

local SomeField...

seems nicer... then having to use self everywhere...

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#92471

FromChris Angelico <rosuav@gmail.com>
Date2015-06-11 21:36 +1000
Message-ID<mailman.392.1434022601.13271.python-list@python.org>
In reply to#92468
On Thu, Jun 11, 2015 at 9:27 PM, Skybuck Flying <skybuck2000@hotmail.com> wrote:
> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...

[toc] | [prev] | [next] | [standalone]


#92472

FromChris Angelico <rosuav@gmail.com>
Date2015-06-11 21:38 +1000
Message-ID<mailman.393.1434022695.13271.python-list@python.org>
In reply to#92468
On Thu, Jun 11, 2015 at 9:27 PM, Skybuck Flying <skybuck2000@hotmail.com> wrote:
> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...

Oops, missent.

If you want this, how about simply declaring all function-local
variables, and having everything else be implicitly global? Or declare
(with data type) all globals, all class attributes, and all locals,
and then let the compiler figure out what you want? Because if you
want ECMAScript or C++, you know where to find them.

ChrisA

[toc] | [prev] | [next] | [standalone]


#92474

FromMRAB <python@mrabarnett.plus.com>
Date2015-06-11 13:16 +0100
Message-ID<mailman.394.1434025019.13271.python-list@python.org>
In reply to#92468
On 2015-06-11 12:27, Skybuck Flying wrote:
> Then again...
>
> I also believe the highest goal for a programming language is "natural
> spoken" language.
>
Natural language is full of ambiguities.

> If "self.somefield" equals 10 then...
>
> Does have some understandable ring to it.
>
> However... time constraints also have to be kept in mind.
>
> In another words if the code looks like
>
> begin of class section
>
Shouldn't that be "beginning of class section"?

> if somefield equals 10 then...
>
>
> end of class section
>
You should have a look at Cobol. If was designed with a more natural-
looking syntax so that business managers could write their own code.

It turned out that the managers didn't write code because programming
harder then they anticipated.

Then there's AppleScript. It also tries to have a more natural-looking
syntax, but the problem is that it's then not so clear what's legal.
For example, it allows "title of window" or "window's title". So what
is the title of the script's title? It's "title of window of me" or
"me's window's title". Yes, "me's", not "my". It's an example of the
"Uncanny Valley".

I prefer a language that doesn't look like a natural language, because
it isn't, that's not its purpose.

> Should be pretty obvious that somefield belongs to class section...
>
> So no need to specify self...
>
> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...
>
"then"? Should be "than"... (That seems to be happening more and more
these days...)

Anyway, the use of "self" is something that's not going to change.

If you don't like it, there are plenty of other programming languages
out there for you to try.

[toc] | [prev] | [next] | [standalone]


#92484

FromThomas Mlynarczyk <thomas@mlynarczyk-webdesign.de>
Date2015-06-11 17:32 +0200
Message-ID<mlc9n7$5br$1@news.albasani.net>
In reply to#92474
On 11/06/15 14:16, MRAB wrote:
> harder then they anticipated.
-----------^
>> seems nicer... then having to use self everywhere...
>>
> "then"? Should be "than"... (That seems to be happening more and more
> these days...)

Indeed :-)

-- 
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)

[toc] | [prev] | [next] | [standalone]


#92483

FromMichael Torrie <torriem@gmail.com>
Date2015-06-11 08:15 -0600
Message-ID<mailman.400.1434032127.13271.python-list@python.org>
In reply to#92465
On 06/11/2015 05:19 AM, Skybuck Flying wrote:
> I haven't written much OO code yet in Python... and don't plan on doing it 
> too...

Except that you already have written OO code in Python with your parser.
 Or at least code that interacts heavily with OO.  Anytime you call a
method on a string like split(), or worked with regular expressions, you
are using OO.  OO permeates Python.  You don't have to use OO design in
your programs, but you will always be working with objects and calling
methods on them.

But anyway, if you don't like "self," use a different name.  Like "skybuck."

class Bar:
    def foo(skybuck, a, b):
        skybuck.a = a
        skybuck.b = b

In other languages with an implicit self or this like C, I find the
ambiguities of scope highly problematic.  Method variables can shadow
instance variables.  It's also difficult for someone unfamiliar with the
code to differentiate between a local variable and an instance variable
as the naked variable name has no qualifier.  I've seen some projects
that apply a "m_" prefix to every instance variable so you can tell them
apart.  Sure that's less typing, but it is super ugly!  Explicitly
providing self not only makes things very clear, it also helps me when
I'm scrolling through code to identify which functions definitions are
bare functions and which are methods of a class.

In short, it's part of the Python language and will not be changing
anytime soon.  So no the interpreter couldn't be written in such a way
that the self can be left out without changing the language's semantics
and definition.

[toc] | [prev] | [next] | [standalone]


#92489

FromRustom Mody <rustompmody@gmail.com>
Date2015-06-11 09:39 -0700
Message-ID<11e2ec7b-73ae-4afc-98f5-e2861a7cc781@googlegroups.com>
In reply to#92465
On Thursday, June 11, 2015 at 4:49:59 PM UTC+5:30, Skybuck Flying wrote:
> Hello,
> 
> I don't like the object orientated part of Python.
> 
> The idea/prospect of having to write "self" everywhere... seems very 
> horrorific and a huge time waster.
> 
> (Perhaps the module thing of python might help in future not sure about 
> that).
> 
> What are your thoughts on the "self" thing/requirement.
> 
> I only want replies from expert programmers, cause we need a language for 
> expert programmers...
> 
> Not noobies that need to be hand-held...
> 
> Personally I think I could do just fine with the "self" keyword everywhere.
> 
> So question is... can the python interpreter/compiler be written in such a 
> way that self can be left out ?
> 
> In other words: Is there any hope... that this part of the language will be 
> cleaned up some day ?
> 
> Are there any tricks to get rid of it ?
> 
> Maybe "white" like in Delphi ?
> 
> I haven't written much OO code yet in Python... and don't plan on doing it 
> too...
> 
> Cause it looks hellish confusing... and clouded/clodded.
> 
> I think I have better things to do then to insert "self" everywhere...
> 
> It's almost like "self" masturbation  LOL.
> 
> Bye,
>   Skybuck =D

I suggest you disentangle your question/crib along 3 axes:

1. Specific grumble about a specific feature -- in this case 'explicit-self'
2. General discomfort with a style/paradigm -- OO

2 itself can be bifurcated along 2 axes
2a. Hard when learning
2b. Painful/stupid for serious/real-world usage

That 2a and 2b were quite separate was well understood in the 70s and
80s when Pascal was widely known.  Today it seems increasingly
forgotten.  eg all the OOP texts that I studied wax endlessly
on circles and ellipses and rectangles and squares and other such
wonders of God's (or OO's) creations.
Today http://en.wikipedia.org/wiki/Circle-ellipse_problem suggests its not
so neat (or useful) as the OO aficionados imagine

[toc] | [prev] | [next] | [standalone]


#92492

Fromsohcahtoa82@gmail.com
Date2015-06-11 09:55 -0700
Message-ID<71ff3f39-9786-47b4-a7ad-5256078c28d9@googlegroups.com>
In reply to#92465
On Thursday, June 11, 2015 at 4:19:59 AM UTC-7, Skybuck Flying wrote:
> Hello,
> 
> I don't like the object orientated part of Python.
> 
> The idea/prospect of having to write "self" everywhere... seems very 
> horrorific and a huge time waster.
> 
> (Perhaps the module thing of python might help in future not sure about 
> that).
> 
> What are your thoughts on the "self" thing/requirement.
> 
> I only want replies from expert programmers, cause we need a language for 
> expert programmers...
> 
> Not noobies that need to be hand-held...
> 
> Personally I think I could do just fine with the "self" keyword everywhere.
> 
> So question is... can the python interpreter/compiler be written in such a 
> way that self can be left out ?
> 
> In other words: Is there any hope... that this part of the language will be 
> cleaned up some day ?
> 
> Are there any tricks to get rid of it ?
> 
> Maybe "white" like in Delphi ?
> 
> I haven't written much OO code yet in Python... and don't plan on doing it 
> too...
> 
> Cause it looks hellish confusing... and clouded/clodded.
> 
> I think I have better things to do then to insert "self" everywhere...
> 
> It's almost like "self" masturbation  LOL.
> 
> Bye,
>   Skybuck =D

We just had a huge thread about the "self" thing less than two weeks ago.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web