What is the semantics meaning of 'object'?

Ian Kelly ian.g.kelly at gmail.com
Tue Jun 25 20:19:55 EDT 2013


On Tue, Jun 25, 2013 at 5:19 PM, Mark Janssen <dreamingforward at 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?



More information about the Python-list mailing list