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


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

Re: operations on types

Started bySteven D'Aprano <steve+comp.lang.python@pearwood.info>
First post2015-06-17 02:04 +0000
Last post2015-06-17 08:39 -0400
Articles 10 — 8 participants

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: operations on types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-17 02:04 +0000
    Re: operations on types Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-16 22:58 -0600
      Re: operations on types Steven D'Aprano <steve@pearwood.info> - 2015-06-17 21:51 +1000
        Re: operations on types Ned Batchelder <ned@nedbatchelder.com> - 2015-06-17 07:26 -0700
          Re: operations on types Steven D'Aprano <steve@pearwood.info> - 2015-06-18 01:42 +1000
            Re: operations on types Michael Torrie <torriem@gmail.com> - 2015-06-17 10:48 -0600
            Re: operations on types Man with No Name <dreamingforward@gmail.com> - 2015-09-06 12:39 -0700
    Re: operations on types Chris Angelico <rosuav@gmail.com> - 2015-06-17 15:33 +1000
    Re: operations on types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-17 15:39 +1000
      Re: operations on types Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-06-17 08:39 -0400

#92720 — Re: operations on types

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2015-06-17 02:04 +0000
SubjectRe: operations on types
Message-ID<5580d5c8$0$1667$c3e8da3$5496439d@news.astraweb.com>
On Tue, 16 Jun 2015 19:24:03 -0500, Dr. John Q. Hacker wrote:

> [Dr. Bigcock wrote:]
>> The current syntax for adding functionality to a class using mix-in
>> style via inheritance list conflates two very different things.

I'm not sure why you are taking "Dr Bigcock" seriously. You know he isn't 
actually a doctor?


>> A different way would be to create (sensible) operations on types:
>>
>> NewType = OldObject + mixin  #object composition
>>
>> Thoughts?
> 
> That's an awesome idea.  It's like a final way to understand and operate
> with metaclasses.

Unfortunately, it has nothing to do with metaclasses.

I can see why:

    NewType = OldType + Mixin

appears more attractive at first glance than:

    class NewType(OldType, Mixin):
        pass


since it saves a lot of boilerplate. But in practice, the body of the 
class is not often "pass". More often, you end up overriding or adding 
new methods. In that case, the suggested syntax has no advantage.

I think that this might be a bit more attractive in statically-typed 
languages. If you wrote:

    class NewType(OldType + Mixin): ...

the compiler could optimize away the intermediary class (OldType+Mixin) 
and just use direct inheritance, but I don't think that would work in 
Python. And a statically-typed language could avoid errors where you 
forget to instantiate a class before doing regular addition:

    result = OldType + x  # oops, meant OldType()


-- 
Steven D'Aprano

[toc] | [next] | [standalone]


#92725

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-06-16 22:58 -0600
Message-ID<mailman.539.1434517186.13271.python-list@python.org>
In reply to#92720
On Tue, Jun 16, 2015 at 8:04 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Tue, 16 Jun 2015 19:24:03 -0500, Dr. John Q. Hacker wrote:
>
>> [Dr. Bigcock wrote:]
>>> The current syntax for adding functionality to a class using mix-in
>>> style via inheritance list conflates two very different things.
>
> I'm not sure why you are taking "Dr Bigcock" seriously. You know he isn't
> actually a doctor?

I'm reasonably certain that they're actually the same person, and he's
now engaging in sockpuppetry [1] by starting conversations with
himself. He's not trying very hard to hide it, signing posts with both
accounts as "zipher" and then lamp-shading that fact by commenting on
it. I can't even find any record that "Dr. Bigcock" ever actually
posted the text that "Dr. John Q. Hacker" is now responding to.

[1] https://en.wikipedia.org/wiki/Sockpuppet_(Internet)

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


#92736

FromSteven D'Aprano <steve@pearwood.info>
Date2015-06-17 21:51 +1000
Message-ID<55815f58$0$1662$c3e8da3$5496439d@news.astraweb.com>
In reply to#92725
On Wed, 17 Jun 2015 02:58 pm, Ian Kelly wrote:

> On Tue, Jun 16, 2015 at 8:04 PM, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
>> On Tue, 16 Jun 2015 19:24:03 -0500, Dr. John Q. Hacker wrote:
>>
>>> [Dr. Bigcock wrote:]
>>>> The current syntax for adding functionality to a class using mix-in
>>>> style via inheritance list conflates two very different things.
>>
>> I'm not sure why you are taking "Dr Bigcock" seriously. You know he isn't
>> actually a doctor?
> 
> I'm reasonably certain that they're actually the same person, and he's
> now engaging in sockpuppetry [1] by starting conversations with
> himself. He's not trying very hard to hide it, signing posts with both
> accounts as "zipher" and then lamp-shading that fact by commenting on
> it. I can't even find any record that "Dr. Bigcock" ever actually
> posted the text that "Dr. John Q. Hacker" is now responding to.


I must admit that the possibility of a sockpuppet crossed my mind too, even
to the point of checking the headers of their posts to see if they came
from the same IP address. (Inconclusive.)

But there was an earlier post from Mark Jansen, a.k.a. Mark
Rosenblitt-Janssen, Dr Bigcock, and Zipher, starting this thread a few days
earlier. I won't link to it, but the relevant headers are:


Subject: operations on types
From: <dreamingforward@gmail.com>
Date: Tue, 16 Jun 2015 09:30:01 -0700 (PDT)
Groups: comp.lang.python


posted from Google Groups. "Dr Hacker", if he really is a doctor or a
hacker, replied via the python-list mailing list, but broke threading when
doing so. (Alas, this is not an unusual thing to happen.)

At the moment, I'm still willing to give Dr Hacker the benefit of the doubt
re the sockpuppet suspicion.



-- 
Steven

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


#92754

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-06-17 07:26 -0700
Message-ID<9312f979-209d-4778-bb9d-9d3204b543fc@googlegroups.com>
In reply to#92736
On Wednesday, June 17, 2015 at 7:52:05 AM UTC-4, Steven D'Aprano wrote:
> On Wed, 17 Jun 2015 02:58 pm, Ian Kelly wrote:
> 
> > On Tue, Jun 16, 2015 at 8:04 PM, Steven D'Aprano
> > <steve+comp.lang.python@pearwood.info> wrote:
> >> I'm not sure why you are taking "Dr Bigcock" seriously. You know he isn't
> >> actually a doctor?
> > 
> > I'm reasonably certain that they're actually the same person, and he's
> > now engaging in sockpuppetry [1] by starting conversations with
> > himself. He's not trying very hard to hide it, signing posts with both
> > accounts as "zipher" and then lamp-shading that fact by commenting on
> > it. I can't even find any record that "Dr. Bigcock" ever actually
> > posted the text that "Dr. John Q. Hacker" is now responding to.
> 
> 
> I must admit that the possibility of a sockpuppet crossed my mind too, even
> to the point of checking the headers of their posts to see if they came
> from the same IP address. (Inconclusive.)
> 
> At the moment, I'm still willing to give Dr Hacker the benefit of the doubt
> re the sockpuppet suspicion.

If you search for "zondervanz", you will find the GitHub account theProhpet
with that email address: https://github.com/theProphet

There you will find a repo with commits like this one where theProphet adds
attributions to Mark Janssen:

https://github.com/theProphet/GlassBeadGame/commit/a1f5082feb76fb0d51b069dc81de2228ff36a221

The INSTALL file lists the owner as Mark:

https://github.com/theProphet/GlassBeadGame/blob/master/INSTALL

The Sourceforge page from that INSTALL is pangaia.sf.net, which 
lists the Twitter account https://twitter.com/Xer0Dynamite, which 
includes this tweet, asking to be called Dr Bigcock:

https://twitter.com/Xer0Dynamite/status/594217063725592577

We've been through this before.  Mark is energetic, and tantalizing,
but not worth engaging.

--Ned.

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


#92764

FromSteven D'Aprano <steve@pearwood.info>
Date2015-06-18 01:42 +1000
Message-ID<55819568$0$1672$c3e8da3$5496439d@news.astraweb.com>
In reply to#92754
On Thu, 18 Jun 2015 12:26 am, Ned Batchelder wrote:

> On Wednesday, June 17, 2015 at 7:52:05 AM UTC-4, Steven D'Aprano wrote:

>> At the moment, I'm still willing to give Dr Hacker the benefit of the
>> doubt re the sockpuppet suspicion.
> 
> If you search for "zondervanz", you will find the GitHub account
> theProhpet with that email address: https://github.com/theProphet
[...]

Ah, well that certainly clears up any lingering doubt. Thanks for your
detective work.


-- 
Steven

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


#92769

FromMichael Torrie <torriem@gmail.com>
Date2015-06-17 10:48 -0600
Message-ID<mailman.559.1434559716.13271.python-list@python.org>
In reply to#92764
On 06/17/2015 09:42 AM, Steven D'Aprano wrote:
> On Thu, 18 Jun 2015 12:26 am, Ned Batchelder wrote:
> 
>> On Wednesday, June 17, 2015 at 7:52:05 AM UTC-4, Steven D'Aprano wrote:
> 
>>> At the moment, I'm still willing to give Dr Hacker the benefit of the
>>> doubt re the sockpuppet suspicion.
>>
>> If you search for "zondervanz", you will find the GitHub account
>> theProhpet with that email address: https://github.com/theProphet
> [...]
> 
> Ah, well that certainly clears up any lingering doubt. Thanks for your
> detective work.

Indeed thank you. I've added this new email address to my filter (though
gmail's filters are rather awkward).

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


#96078

FromMan with No Name <dreamingforward@gmail.com>
Date2015-09-06 12:39 -0700
Message-ID<87a143a8-6588-4825-b4cf-4854fcb2f01f@googlegroups.com>
In reply to#92764
 > Ah, well that certainly clears up any lingering doubt. Thanks for your
> detective work.

I assure you, you have not understood.  I suggest you study Fernando Pessoa:

The Book of Disquiet (Livro do Desassossego: Composto por Bernardo Soares, ajudante de guarda-livros na cidade de Lisboa)

-M

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


#92726

FromChris Angelico <rosuav@gmail.com>
Date2015-06-17 15:33 +1000
Message-ID<mailman.540.1434519211.13271.python-list@python.org>
In reply to#92720
On Wed, Jun 17, 2015 at 2:58 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> I'm reasonably certain that they're actually the same person, and he's
> now engaging in sockpuppetry [1] by starting conversations with
> himself.

I used to think there was a limit to the depths of human boredom. Then
I met the internet, and learned better.

ChrisA

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


#92727

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2015-06-17 15:39 +1000
Message-ID<558107fc$0$11127$c3e8da3@news.astraweb.com>
In reply to#92720
On Wednesday 17 June 2015 12:42, Dr. John Q. Hacker wrote:

> On Tue, Jun 16, 2015 at 9:04 PM, Steven D'Aprano <
> steve+comp.lang.python@pearwood.info> wrote:
> 
>> On Tue, 16 Jun 2015 19:24:03 -0500, Dr. John Q. Hacker wrote:
>>
>> > [Dr. Bigcock wrote:]
>> >> The current syntax for adding functionality to a class using mix-in
>> >> style via inheritance list conflates two very different things.
>>
>> I'm not sure why you are taking "Dr Bigcock" seriously. You know he isn't
>> actually a doctor?
>>
> 
> Actually, I asked him.  He said he was has a PhD in Theology.

You believe somebody calling himself "Dr Bigcock" (among other pseudonyms)? 
Just how much credibility does somebody calling themselves Bigcock get? Even 
in the "Carry On" movies they didn't use any names as unsubtle as that.

https://www.youtube.com/watch?v=wcBOX1JBcjQ

Besides, I have a Doctorate of Divinity, and I'm not a doctor either.


>> > That's an awesome idea.  It's like a final way to understand and
>> > operate
>> > > with metaclasses.
>> >
>> > Unfortunately, it has nothing to do with metaclasses.
>>
> 
>  No, it *does*:  it's operations on classes themselves (i.e. types) and
>  not
> on *instantiations* of classes.  If that isn't metaclassing, then python's
> been calling it wrong.

Python's definition of "metaclass" (the class of a class) is the same as 
that used by (at least) Objective C and Smalltalk. If you're going to argue 
that *Smalltalk* is wrong, well, good luck with that, Smalltalk invented the 
concept.

http://www.cocoawithlove.com/2010/01/what-is-meta-class-in-objective-c.html

http://pharo.gforge.inria.fr/PBE1/PBE1ch14.html

If you think there's another definition of "metaclass" in widespread use, 
please give some citations or links.

What I will accept is that implementing class composition using the + 
operator *could* be implemented via the metaclass, at least in languages 
with metaclasses. But that's not the only way to do it. Java, for example, 
has no metaclasses (classes are not themselves objects in Java), but the 
Java language could easily define "Type + Type" as a way of composing types. 
It just wouldn't work via the metaclass.

That's what I mean by "it has nothing to do with metaclasses" -- you can 
implement this without using metaclasses.


>> I can see why:
>> >
>> >     NewType = OldType + Mixin
>> >
>> > appears more attractive at first glance than:
>> >
>> >     class NewType(OldType, Mixin):
>> >         pass
>> >
>> > since it saves a lot of boilerplate. But in practice, the body of the
>> > class is not often "pass". More often, you end up overriding or adding
>> > new methods. In that case, the suggested syntax has no advantage.
>>
> 
> Adding new methods is exactly what this syntax is supposed to do.

No, it creates a new class which inherits *existing* methods belonging to 
the two composed classes, OldType and Mixin. It doesn't create any methods 
that don't already exist.


> The tricky part is overriding existing methods. 

Precisely. If you want NewType.method to override either parent 
(OldType.method and/or Mixin.method) you need more than just a type 
composition operator. In Python you would use a class statement:

class NewType(OldType + Mixin):
    def method(self):
        ...


You would also do the same to add a new method not provided by either 
OldType or the Mixin.


-- 
Steve

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


#92737

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-06-17 08:39 -0400
Message-ID<mailman.546.1434544789.13271.python-list@python.org>
In reply to#92727
On Wed, 17 Jun 2015 15:39:03 +1000, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following:

>
>Besides, I have a Doctorate of Divinity, and I'm not a doctor either.
>
	In a box somewhere, I should still have certificates for Doctor of
Immortality, and (the more meaningful one as I recall, since I had to send
back a two page multiple choice exam) a Doctor of BS (Biblical Studies).
-- 
	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