What is the semantics meaning of 'object'?

Chris Angelico rosuav at gmail.com
Wed Jun 26 03:25:49 EDT 2013


On Wed, Jun 26, 2013 at 11:07 AM, Mark Janssen
<dreamingforward at 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



More information about the Python-list mailing list