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


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

What is the semantics meaning of 'object'?

Started byAdam <jiang.adam@gmail.com>
First post2013-06-22 19:58 -0700
Last post2013-06-23 13:12 -0700
Articles 7 on this page of 67 — 12 participants

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


Contents

  What is the semantics meaning of 'object'? Adam <jiang.adam@gmail.com> - 2013-06-22 19:58 -0700
    Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 03:20 +0000
      Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-22 22:27 -0600
        Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 05:23 +0000
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-22 23:40 -0600
            Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 17:29 +0000
              Re: What is the semantics meaning of 'object'? Rotwang <sg552@hotmail.co.uk> - 2013-06-24 02:53 +0100
                Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 06:31 +0000
                  Re: What is the semantics meaning of 'object'? Rotwang <sg552@hotmail.co.uk> - 2013-06-24 16:00 +0100
                    Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-24 11:23 -0600
      Re: What is the semantics meaning of 'object'? Adam Jiang <jiang.adam@gmail.com> - 2013-06-23 22:35 +0900
      Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 10:15 -0600
        Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 16:35 +0000
          Re: What is the semantics meaning of 'object'? Roy Smith <roy@panix.com> - 2013-06-23 12:49 -0400
            Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 11:08 -0600
              Re: What is the semantics meaning of 'object'? Roy Smith <roy@panix.com> - 2013-06-23 14:14 -0400
            Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 11:18 -0600
              Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 17:36 +0000
                Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 12:04 -0600
                  Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 18:50 +0000
                    Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 13:09 -0600
                      Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 01:12 +0000
                    Re: What is the semantics meaning of 'object'? Roy Smith <roy@panix.com> - 2013-06-23 15:24 -0400
                      Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 01:27 +0000
                        Re: What is the semantics meaning of 'object'? Roy Smith <roy@panix.com> - 2013-06-23 21:38 -0400
                          Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 08:06 +0000
                            Re: What is the semantics meaning of 'object'? Roy Smith <roy@panix.com> - 2013-06-24 08:41 -0400
                    Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-24 08:58 -0700
                      Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 23:51 +0000
                    Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-24 11:26 -0600
                    Re: What is the semantics meaning of 'object'? Ethan Furman <ethan@stoneleaf.us> - 2013-06-26 13:14 -0700
                      Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-26 23:54 +0000
                        Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-26 19:03 -0600
                        Re: What is the semantics meaning of 'object'? Ethan Furman <ethan@stoneleaf.us> - 2013-06-26 17:38 -0700
            Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-23 18:46 +0000
              Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-23 13:05 -0600
              Re: What is the semantics meaning of 'object'? Ethan Furman <ethan@stoneleaf.us> - 2013-06-26 13:37 -0700
            Re: What is the semantics meaning of 'object'? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-23 13:33 -0700
          Re: What is the semantics meaning of 'object'? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-23 21:33 +0200
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 11:44 -0600
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 14:58 -0700
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 08:17 +1000
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 16:21 -0600
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 16:25 -0600
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 15:29 -0700
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 15:27 -0700
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 15:38 -0700
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 08:39 +1000
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 08:47 +1000
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 08:57 +1000
            Re: What is the semantics meaning of 'object'? Rotwang <sg552@hotmail.co.uk> - 2013-06-26 16:16 +0100
              Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-27 01:23 +1000
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 17:07 -0600
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 09:08 +1000
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 17:10 -0600
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 16:19 -0700
            Re: What is the semantics meaning of 'object'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-26 08:36 +0000
            Re: What is the semantics meaning of 'object'? alex23 <wuwei23@gmail.com> - 2013-06-28 10:19 +1000
              Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-28 11:55 -0700
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 16:00 -0700
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 18:19 -0600
          Re: What is the semantics meaning of 'object'? Mark Janssen <dreamingforward@gmail.com> - 2013-06-25 18:07 -0700
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 17:25 +1000
          Re: What is the semantics meaning of 'object'? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-26 02:53 -0600
          Re: What is the semantics meaning of 'object'? Chris Angelico <rosuav@gmail.com> - 2013-06-26 09:54 +1000
          Re: What is the semantics meaning of 'object'? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-26 12:56 +0200
        Re: What is the semantics meaning of 'object'? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-23 13:12 -0700

Page 4 of 4 — ← Prev page 1 2 3 [4]


#49214

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-06-25 18:19 -0600
Message-ID<mailman.3866.1372206043.3114.python-list@python.org>
In reply to#48990
On Tue, Jun 25, 2013 at 5:19 PM, Mark Janssen <dreamingforward@gmail.com> wrote:
>>> Combining integers with sets I can make
>>> a Rational class and have infinite-precision arithmetic, for example.
>>
>> Combining two integers lets you make a Rational.
>
> Ah, but what is going to group them together?  You see you've already
> gotten seduced.  Python already uses a set to group them together --
> it's called a Dict and it's in every Class object.

When you inherit a "set" to make a Rational, you're making the
statement (to the interpreter, if nothing else) that a Rational is-a
set.

When a Python class uses an instance dict to store the numerator and
denominator of a Fraction, it's not *inheriting* Fraction from dict,
which is good because a Fraction is not a dict.  It's merely *using* a
dict.  It comes back once again to the distinction between inheritance
and composition.

>>  Also, you need an
>> ordered set - is the set {5,3} greater or less than the set {2} when
>> you interpret them as rationals?
>
> The ordering (and hence the interpretation) is done WITHIN the Class
> (i.e. the SET as I say above).

So "set" is just your name for a class?  I understood earlier that
with integers and sets you were trying to derive your type system from
number theory.  Now it sounds like you want sets to be containers of
attributes.  Which is it?

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


#49221

FromMark Janssen <dreamingforward@gmail.com>
Date2013-06-25 18:07 -0700
Message-ID<mailman.3871.1372208844.3114.python-list@python.org>
In reply to#48990
>>> Combining two integers lets you make a Rational.
>>
>> Ah, but what is going to group them together?  You see you've already
>> gotten seduced.  Python already uses a set to group them together --
>> it's called a Dict and it's in every Class object.
>
> When you inherit a "set" to make a Rational, you're making the
> statement (to the interpreter, if nothing else) that a Rational is-a
> set.

No you don't *inherit* a set to make a Rational, although you gain a
set to make it.  It's a subtle thing, because at the center of it
articulates the very difference between a piece of data and a
container to hold that data.  Or is the container the data?

C++ already solves this di-lemma.  It made "class" which is exactly
like a "struct", but hides all it's data members.  That critical
distinction makes all the difference.  I don't know how many people on
the list really appreciate it.

-- 
MarkJ
Tacoma, Washington

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


#49231

FromChris Angelico <rosuav@gmail.com>
Date2013-06-26 17:25 +1000
Message-ID<mailman.3877.1372231552.3114.python-list@python.org>
In reply to#48990
On Wed, Jun 26, 2013 at 11:07 AM, Mark Janssen
<dreamingforward@gmail.com> wrote:
>>>> Combining two integers lets you make a Rational.
>>>
>>> Ah, but what is going to group them together?  You see you've already
>>> gotten seduced.  Python already uses a set to group them together --
>>> it's called a Dict and it's in every Class object.
>>
>> When you inherit a "set" to make a Rational, you're making the
>> statement (to the interpreter, if nothing else) that a Rational is-a
>> set.
>
> No you don't *inherit* a set to make a Rational, although you gain a
> set to make it.  It's a subtle thing, because at the center of it
> articulates the very difference between a piece of data and a
> container to hold that data.  Or is the container the data?
>
> C++ already solves this di-lemma.  It made "class" which is exactly
> like a "struct", but hides all it's data members.  That critical
> distinction makes all the difference.  I don't know how many people on
> the list really appreciate it.

I certainly don't. In fact, I hardly use "class" in C++ these days - I
just use "struct" and let the members be public. How is that
significant?

The thing you're completely missing, though, is that NONE of what
you're saying has anything to do with inheritance or super(). It's all
composition.

ChrisA

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


#49237

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-06-26 02:53 -0600
Message-ID<mailman.3880.1372236848.3114.python-list@python.org>
In reply to#48990
On Tue, Jun 25, 2013 at 7:07 PM, Mark Janssen <dreamingforward@gmail.com> wrote:
>> When you inherit a "set" to make a Rational, you're making the
>> statement (to the interpreter, if nothing else) that a Rational is-a
>> set.
>
> No you don't *inherit* a set to make a Rational, although you gain a
> set to make it.

Okay, then.  Since you started this discussion from the topic of
multiple inheritance I was under the impression that you were talking
about using inheritance to construct Rationals from integers and sets.
 Evidently that is not so, and you've been talking about composition
all along, in which case I have no idea how any of this relates to
your original suggestion of putting superclasses "in charge" of their
subclasses.

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


#49240

FromChris Angelico <rosuav@gmail.com>
Date2013-06-26 09:54 +1000
Message-ID<mailman.3882.1372243291.3114.python-list@python.org>
In reply to#48990
On Wed, Jun 26, 2013 at 9:19 AM, Mark Janssen <dreamingforward@gmail.com> wrote:
> Did you ever hear of the Glass Bead Game?

Yeah, it's Magic: The Gathering and its counters.

http://www.wizards.com/magic/magazine/Article.aspx?x=mtgcom/daily/mr195

:)

ChrisA

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


#49247

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2013-06-26 12:56 +0200
Message-ID<mailman.3888.1372244196.3114.python-list@python.org>
In reply to#48990
Op 26-06-13 00:27, Mark Janssen schreef:
>> The main problem is getting to the top/end of the call chain. Classic
>> example is with __init__, but the same problem can also happen with
>> other calls. Just a crazy theory, but would it be possible to
>> construct a black-holing object that, for any given method name,
>> returns a dummy function that ignores its args? (Other forms of
>> attribute lookup aren't going to be a problem, I think, so this can be
>> just methods/functions.) Then you just subclass from that all the
>> time, instead of from object itself, and you should be able to safely
>> call super's methods with whatever kwargs you haven't yourself
>> processed. Would that work?
>>
>> Caveat: I have not done much with MI in Python, so my idea may be
>> complete balderdash.
> Here's how it *should* be made:  the most superest, most badassed
> object should take care of its children.  New instances should
> automatically call up the super chain (and not leave it up to the
> subclasses), so that the parent classes can take care of the chil'en.
>  When something goes wrong the parent class has to look in and see
> what's wrong.
Could you explain why you think it should work this way? Maybe illustrate
how this is supposed to work.

Let take a very simple example. We have a class that works with a stream
(anything with a write method).

class Streamer:
    def __init__(self, strm):
        ...

Now we find that we very often use this class with a file, so we would
like to make a subclass that takes a filename as parameter. This we would 
write somehow like the following

class Filer(Streamer):
    def __init__(self, fn):
        fl = open(fn, "a+")
        super.__init__(fl)
        ...


Can you explain how this example should be written en work as you view things?

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


#49004

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2013-06-23 13:12 -0700
Message-ID<e2c3a2c1-3ca1-4154-9067-edf233558201@googlegroups.com>
In reply to#48988
On Sunday, June 23, 2013 11:15:38 AM UTC-5, Ian wrote:
> If you're worried about efficiency, you can also
> explicitly name the superclass in order to call the method
> directly, like:

I'm NOT worried about efficiency, i worried about
readability, and using super (when super is NOT absolutely
required) is folly.
 
>         A.__init__(self, arg)

What you've done here is correct, the only flaw is that you
choose to do this for all the wrong reasons. 

...GET YOUR PRIORITIES IN ORDER!

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

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


csiph-web