On Tue, Jun 25, 2013 at 5:19 PM, Mark Janssen <dreamingforw...@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? -- http://mail.python.org/mailman/listinfo/python-list