deriving from float or int

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Tue Feb 21 02:22:36 EST 2006


Russ enlightened us with:
> Does it ever make sense to derive a class from a basic type such as
> float or int? Suppose, for example, that I want to create a class
> for physical scalars with units.

That makes sense.

> I thought about deriving from float, then adding the units. I played
> around with it a bit, but it doesn't seem to work very well. Am I
> missing something here? Thanks.

Yeah, you forgot to include a magical 'make the reader psychic' text
;-)

An explanation of what you did and what went wrong would be useful in
answering your question.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list