[Python-Dev] PEP 285, inheritance reversed
Scott Gilbert
xscottg@yahoo.com
2002年3月15日 13:18:47 -0800 (PST)
Being a newbie on this list, I was hoping to keep my mouth shut a
little longer and just wait to see how your discussions rounded out,
but since the topic seems to have died, I figure I'll make my say:
Isn't the inheritance between bool and int backwards?
ints can be used as bools
longs can be used as bools
floats can be used as bools
lists can be used as bools
dicts can be used as bools
strings can be used as bools
etc... can be used as bools
bools can't be promoted to dicts
bools can't be promoted to lists
bools can be promoted to ints, longs, floats, and strings, (and a few
others) but only in a limited way.
In some OO fashion, doesn't all of this imply that ints, longs, lists,
dicts, strings, ... should derive from bool instead of bool deriving
from int? Then bool implements __int__, __long__, __str__, __repr__,
or the C extension equivalent to promote where needed?
I suppose that breaks anything that assumes int, long, str, dict, list
derive from object directly though... Otherwise does it cause a
problem?
Ok. I'll go back to being quiet for a bit.
Cheers,
-Scott
ps: The intro to the list said I should introduce myself... I'm a
software engineer living and working in Tucson, Arizona. The company I
work for has started using Python in a larger and larger capacity for
digital signal processing and other misc scientific computing. I've
followed the language for 3-4 of years now.
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/