Karim wrote:
[snip]
If you don't want to use a factory function I believe you can do this:
class MyNumber(object):
def __new__(cls, n):
if n<= 100:
cls = SmallNumbers
else:
cls = BigNumbers
return object.__new__(cls, n)
...
Chard.
Very beautiful code great alternative to factory method!
To memorize this pythonic way.
Regards
Karim
Do you think that the MyNumber constructor returning something else
than a MyNumber instance is the pythonic way ? It would rather be the
cryptonic way ! (haha)
JM
--
http://mail.python.org/mailman/listinfo/python-list