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


Groups > comp.lang.python > #81455

Re: I have no class

From Dan Sommers <dan@tombstonezero.net>
Newsgroups comp.lang.python
Subject Re: I have no class
Date 2014-11-24 13:44 +0000
Organization A noiseless patient Spider
Message-ID <m4vcni$97h$1@dont-email.me> (permalink)
References (8 earlier) <mailman.16192.1416759279.18130.python-list@python.org> <up347a14v7v65meph33k53kas3jkqgmoo5@4ax.com> <66b13454-3503-4111-bf8e-58ce79ef00aa@googlegroups.com> <5472b24c$0$12979$c3e8da3$5496439d@news.astraweb.com> <mailman.16224.1416805895.18130.python-list@python.org>

Show all headers | View raw


On Mon, 24 Nov 2014 16:11:32 +1100, Chris Angelico wrote:

> On Mon, Nov 24, 2014 at 3:21 PM, Steven D'Aprano <steve@pearwood.info> wrote:
>> On Sun, 23 Nov 2014 09:02:57 -0800, Rustom Mody wrote:
>>
>>> Python is a bit odd in the OO-world in that it prioritizes "Explicit is
>>> better than implicit" over convenience.
>>>
>>> Notice that you use self.throw where in most other OOP languages you
>>> would use just throw.
>>
>> I don't think that is correct. I think that most OOP languages are like
>> Python, and use a special variable to reference the current instance:
>>
>> In some of these languages, the use of "this/self/me" is optional, but
>> I'm not aware of *any* OOP language where there is no named reference to
>> the current object at all.
> 
> I believe his point is that Python, unlike every other language he can
> think of, requires "self.x" instead of just "x". Every language needs
> a way to say "current object", but not every language needs you to say
> that for every member reference. C++, Pike, and Java let you
> short-hand that. (They're all deriving from the same syntactic style
> anyway.) JavaScript doesn't, I believe, although its variable scoping
> rules are some of the most insane I've ever met, so there might be a
> way to shortcut it. If your experience of OO is mainly from C++/Java
> family languages, then yes, Python will seem odd.

And then, at least in C++, you see coding standards that demand that
member variables (aka instance variables aka attributes) be named in
such a way that you can tell that they're member variables and not local
variables (one common convenstion is that all member variables begin
with "m_").  IMO, that's a concession that all that implicitness and
convenience just causes confusion.  In Python, the names of all instance
attributes begin with "self."

Dan

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 21:47 -0500
  Re: I have no class random832@fastmail.us - 2014-11-22 22:08 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:16 -0500
  Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:09 -0800
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:18 -0500
  Re: I have no class Ned Batchelder <ned@nedbatchelder.com> - 2014-11-22 22:14 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:35 -0500
      Re: I have no class Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-22 22:52 -0500
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:15 -0500
          Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-23 17:00 +1100
            Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 05:52 -0500
              Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 10:16 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 10:54 -0500
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 11:14 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 11:49 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 03:59 +1100
                Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-23 09:02 -0800
                Re: I have no class Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:21 +0000
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:11 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:11 +1100
                Re: I have no class Dan Sommers <dan@tombstonezero.net> - 2014-11-24 13:44 +0000
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-25 00:48 +1100
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:20 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:21 +1100
                Re: I have no class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-24 13:47 -0500
      Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:55 -0800
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:19 -0500
        Re: I have no class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-23 15:35 +0000

csiph-web