Richard Thomas <chards...@gmail.com> writes:

> 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)

But you have to be aware that the initializers are not called in this way.

-- 
Piet van Oostrum <p...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Nu Fair Trade woonartikelen op http://www.zylja.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to