Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67511 > unrolled thread
| Started by | Westley Martínez <anikom15@gmail.com> |
|---|---|
| First post | 2014-03-02 22:16 -0800 |
| Last post | 2014-03-04 19:25 -0500 |
| Articles | 18 — 13 participants |
Back to article view | Back to comp.lang.python
Origin of 'self' Westley Martínez <anikom15@gmail.com> - 2014-03-02 22:16 -0800
Re:Origin of 'self' Dave Angel <davea@davea.name> - 2014-03-03 01:49 -0500
Re: Origin of 'self' Steven D'Aprano <steve@pearwood.info> - 2014-03-03 06:52 +0000
Re: Origin of 'self' Westley Martínez <anikom15@gmail.com> - 2014-03-05 17:56 -0800
Re: Origin of 'self' Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-06 17:43 +0000
Re: Origin of 'self' Marko Rauhamaa <marko@pacujo.net> - 2014-03-06 19:46 +0200
Re: Origin of 'self' Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-03 00:03 -0700
Re: Origin of 'self' Terry Reedy <tjreedy@udel.edu> - 2014-03-03 13:35 -0500
Re: Origin of 'self' Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-03-03 21:09 -0500
Re: Origin of 'self' Roy Smith <roy@panix.com> - 2014-03-03 21:14 -0500
Re: Origin of 'self' Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-03-04 19:27 -0500
Re: Origin of 'self' Chris Angelico <rosuav@gmail.com> - 2014-03-04 13:13 +1100
Re: Origin of 'self' MRAB <python@mrabarnett.plus.com> - 2014-03-04 12:47 +0000
Re: Origin of 'self' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 14:27 +0000
Re: Origin of 'self' MRAB <python@mrabarnett.plus.com> - 2014-03-04 17:10 +0000
Re: Origin of 'self' Rustom Mody <rustompmody@gmail.com> - 2014-03-04 19:45 -0800
Re: Origin of 'self' MRAB <python@mrabarnett.plus.com> - 2014-03-05 03:58 +0000
Re: Origin of 'self' Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-03-04 19:25 -0500
| From | Westley Martínez <anikom15@gmail.com> |
|---|---|
| Date | 2014-03-02 22:16 -0800 |
| Subject | Origin of 'self' |
| Message-ID | <dc4f4ee0-8380-4141-97bd-99d6e67d5e2d@googlegroups.com> |
I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless. Sincerely, Westley Martínez
[toc] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-03-03 01:49 -0500 |
| Message-ID | <mailman.7624.1393829102.18130.python-list@python.org> |
| In reply to | #67511 |
Westley Martínez <anikom15@gmail.com> Wrote in message: > I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless. > I couldn't tell you the history, but I can say it makes sense to me. In c++, this is a pointer, and the name this seems reasonable. But in python it's a reference, a reference to myself. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2014-03-03 06:52 +0000 |
| Message-ID | <531426b8$0$2923$c3e8da3$76491128@news.astraweb.com> |
| In reply to | #67511 |
On Sun, 02 Mar 2014 22:16:31 -0800, Westley Martínez wrote: > I understand that in an object method the first argument in the object > itself, called self. However, it doesn't have to be called self, and > can be called anything. So my question is why is it called self and not > this like from C++ and Java. It's kind of a silly question, but one > that I'm curious about nevertheless. A better question is why C++ and Java used "this" instead of "self" like Smalltalk. It's fairly clear that Java copied C++, but why did C++ use "this"? http://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28object-oriented_programming%29#Special_variables As far as I can tell, Simula 67 (the first OOP programming language) doesn't seem to use a standard name for the current instance, it appears to be unneeded. But Simula 67 was the inspiration for Smalltalk, invented by Alan Kay at Xerox PARC in the 1970s, and Smalltalk used "self". Virtually everything in OOP that followed was influenced by or derived from Smalltalk. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Westley Martínez <anikom15@gmail.com> |
|---|---|
| Date | 2014-03-05 17:56 -0800 |
| Message-ID | <1634feec-9f23-4f46-bd38-f5f6ef3b0113@googlegroups.com> |
| In reply to | #67514 |
Why did C++ use this? I don't really like this. It doesn't sound right. I think it's because I have trouble saying the th sound without getting my mouth full of spit. Thankfully you don't often need to use this in C++ like you do with self in Python.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-03-06 17:43 +0000 |
| Message-ID | <mailman.7868.1394127826.18130.python-list@python.org> |
| In reply to | #67907 |
On 06/03/2014 01:56, Westley Martínez wrote: > Why did C++ use this? I don't really like this. It doesn't sound right. I think it's because I have trouble saying the th sound without getting my mouth full of spit. > > Thankfully you don't often need to use this in C++ like you do with self in Python. > You don't need to use self, you can call it anything you like, but you'll not be particularly popular if you do this. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-06 19:46 +0200 |
| Message-ID | <87pplzqkyg.fsf@elektro.pacujo.net> |
| In reply to | #67907 |
Westley Martínez <anikom15@gmail.com>: > Thankfully you don't often need to use this in C++ like you do with > self in Python. Self pity is not attractive. Marko
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-03-03 00:03 -0700 |
| Message-ID | <mailman.7626.1393830241.18130.python-list@python.org> |
| In reply to | #67511 |
On Sun, Mar 2, 2014 at 11:16 PM, Westley Martínez <anikom15@gmail.com> wrote: > I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless. The idea of requiring references to attributes and methods of self to be explicit comes from Modula-3; likely the naming convention follows the same lineage.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-03-03 13:35 -0500 |
| Message-ID | <mailman.7652.1393872007.18130.python-list@python.org> |
| In reply to | #67511 |
On 3/3/2014 1:16 AM, Westley Martínez wrote: > I understand that in an object method the first argument in the > object itself, called self. However, it doesn't have to be called > self, and can be called anything. So my question is why is it called > self and not this like from C++ and Java. It's kind of a silly > question, but one that I'm curious about nevertheless. Three responses and I learned or had something pointed out in each. That is a better track record than most threads. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-03-03 21:09 -0500 |
| Message-ID | <mailman.7684.1393898999.18130.python-list@python.org> |
| In reply to | #67511 |
On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez
<anikom15@gmail.com> declaimed the following:
>I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless.
>
It didn't want to be egotistical (as I recall, M$ VB uses "me")
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-03 21:14 -0500 |
| Message-ID | <roy-E7C2E0.21144403032014@news.panix.com> |
| In reply to | #67624 |
In article <mailman.7684.1393898999.18130.python-list@python.org>, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez > <anikom15@gmail.com> declaimed the following: > > >I understand that in an object method the first argument in the object > >itself, called self. However, it doesn't have to be called self, and can be > >called anything. So my question is why is it called self and not this like > >from C++ and Java. It's kind of a silly question, but one that I'm curious > >about nevertheless. > > > > It didn't want to be egotistical (as I recall, M$ VB uses "me") And Freud uses "id", but that was taken already in Python :-)
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-03-04 19:27 -0500 |
| Message-ID | <mailman.7779.1393980305.18130.python-list@python.org> |
| In reply to | #67627 |
On Mon, 03 Mar 2014 21:14:44 -0500, Roy Smith <roy@panix.com> declaimed the
following:
>In article <mailman.7684.1393898999.18130.python-list@python.org>,
> Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>
>> On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez
>> <anikom15@gmail.com> declaimed the following:
>>
>> >I understand that in an object method the first argument in the object
>> >itself, called self. However, it doesn't have to be called self, and can be
>> >called anything. So my question is why is it called self and not this like
>> >from C++ and Java. It's kind of a silly question, but one that I'm curious
>> >about nevertheless.
>> >
>>
>> It didn't want to be egotistical (as I recall, M$ VB uses "me")
>
>And Freud uses "id", but that was taken already in Python :-)
Not to mention that the "id" is not the "ego"...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-04 13:13 +1100 |
| Message-ID | <mailman.7685.1393899213.18130.python-list@python.org> |
| In reply to | #67511 |
On Tue, Mar 4, 2014 at 1:09 PM, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez > <anikom15@gmail.com> declaimed the following: > >>I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless. >> > > It didn't want to be egotistical (as I recall, M$ VB uses "me") ALL language designers are egotistical. Goes with the territory. (Larry Wall said that, I believe, regarding Perl.) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2014-03-04 12:47 +0000 |
| Message-ID | <mailman.7706.1393937237.18130.python-list@python.org> |
| In reply to | #67511 |
On 2014-03-04 02:09, Dennis Lee Bieber wrote: > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez > <anikom15@gmail.com> declaimed the following: > >> I understand that in an object method the first argument in the >> object itself, called self. However, it doesn't have to be called >> self, and can be called anything. So my question is why is it >> called self and not this like from C++ and Java. It's kind of a >> silly question, but one that I'm curious about nevertheless. >> > > It didn't want to be egotistical (as I recall, M$ VB uses "me") > So does AppleScript. <OT> In AppleScript a script can refer to the title of a window as "title of window" or "window's title", and it can refer to the title of its own window as "title of window of me" or "me's window's title". Consistent, yes, but bad English. That's why I prefer a programming language not to be too much like a natural language. :-) </OT>
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-03-04 14:27 +0000 |
| Message-ID | <5315e2b9$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #67668 |
On Tue, 04 Mar 2014 12:47:09 +0000, MRAB wrote: > In AppleScript a script can refer to the title of a window as "title of > window" or "window's title", and it can refer to the title of its own > window as "title of window of me" or "me's window's title". Consistent, > yes, but bad English. > > That's why I prefer a programming language not to be too much like a > natural language. :-) But the problem with that is not that it is too much like a natural language, but too little like a natural language. -- Steven D'Aprano http://import-that.dreamwidth.org/
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2014-03-04 17:10 +0000 |
| Message-ID | <mailman.7732.1393953012.18130.python-list@python.org> |
| In reply to | #67680 |
On 2014-03-04 14:27, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 12:47:09 +0000, MRAB wrote: > >> In AppleScript a script can refer to the title of a window as >> "title of window" or "window's title", and it can refer to the >> title of its own window as "title of window of me" or "me's >> window's title". Consistent, yes, but bad English. >> >> That's why I prefer a programming language not to be too much like >> a natural language. :-) > > But the problem with that is not that it is too much like a natural > language, but too little like a natural language. > The more it's like a natural language, the more intelligent you expect it to be, and the more you expect it to be able to work out ambiguities for itself.
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-03-04 19:45 -0800 |
| Message-ID | <49693163-cb83-4651-81c5-241fad6145d5@googlegroups.com> |
| In reply to | #67668 |
On Tuesday, March 4, 2014 6:17:09 PM UTC+5:30, MRAB wrote: > On 2014-03-04 02:09, Dennis Lee Bieber wrote: > > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez declaimed: > >> I understand that in an object method the first argument in the > >> object itself, called self. However, it doesn't have to be called > >> self, and can be called anything. So my question is why is it > >> called self and not this like from C++ and Java. It's kind of a > >> silly question, but one that I'm curious about nevertheless. > > It didn't want to be egotistical (as I recall, M$ VB uses "me") > So does AppleScript. > <OT> > In AppleScript a script can refer to the title of a window as "title of > window" or "window's title", and it can refer to the title of its own > window as "title of window of me" or "me's window's title". Consistent, > yes, but bad English. > That's why I prefer a programming language not to be too much like a > natural language. :-) > </OT> <Continue-OT> There could be other conclusions. Such as that English could learn from AppleScript to not make bogus distinctions between me and my. Or latin in which case is sufficiently explicit that word-order does not matter <Even-more-OT> Reminds me of "How do we know whether smoking causes cancer or cancer causes smoking?" </Even-more-OT> </Continue-OT>
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2014-03-05 03:58 +0000 |
| Message-ID | <mailman.7786.1393991916.18130.python-list@python.org> |
| In reply to | #67788 |
On 2014-03-05 03:45, Rustom Mody wrote: > On Tuesday, March 4, 2014 6:17:09 PM UTC+5:30, MRAB wrote: >> On 2014-03-04 02:09, Dennis Lee Bieber wrote: >> > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez declaimed: > >> >> I understand that in an object method the first argument in the >> >> object itself, called self. However, it doesn't have to be called >> >> self, and can be called anything. So my question is why is it >> >> called self and not this like from C++ and Java. It's kind of a >> >> silly question, but one that I'm curious about nevertheless. >> > It didn't want to be egotistical (as I recall, M$ VB uses "me") >> So does AppleScript. > >> <OT> > >> In AppleScript a script can refer to the title of a window as "title of >> window" or "window's title", and it can refer to the title of its own >> window as "title of window of me" or "me's window's title". Consistent, >> yes, but bad English. > >> That's why I prefer a programming language not to be too much like a >> natural language. :-) > >> </OT> > > <Continue-OT> > > There could be other conclusions. Such as that English could learn > from AppleScript to not make bogus distinctions between me and my. Or > latin in which case is sufficiently explicit that word-order does not matter > Latin's not that explicit: the endings aren't unique within a declension. > <Even-more-OT> > Reminds me of > "How do we know whether smoking causes cancer or cancer causes smoking?" > </Even-more-OT> > > </Continue-OT> >
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-03-04 19:25 -0500 |
| Message-ID | <mailman.7775.1393979407.18130.python-list@python.org> |
| In reply to | #67511 |
On Tue, 4 Mar 2014 13:13:24 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following:
>On Tue, Mar 4, 2014 at 1:09 PM, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>> On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez
>> <anikom15@gmail.com> declaimed the following:
>>
>>>I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kind of a silly question, but one that I'm curious about nevertheless.
>>>
>>
>> It didn't want to be egotistical (as I recall, M$ VB uses "me")
>
>ALL language designers are egotistical. Goes with the territory.
>
Ah, but I was referring to the language itself, not the designer...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web