Re: subclassing Decimal

2005-02-22 Thread Nick Coghlan
[EMAIL PROTECTED] wrote:
yea-though-I-walk-thru-the-valley-of-__new__-I-will-fear-no-super-ly
That's beautiful }:
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


subclassing Decimal

2005-02-21 Thread [EMAIL PROTECTED]
I was interested in playing around with Decimal and
subclassing it.  For example, if I wanted a special
class to permit floats to be automatically converted
to strings.

from decimal import Decimal

class MyDecimal(Decimal):
def __init__(self, value):
if isinstance(value, float):
... initialize using str(float) ...

In the classic days, I would have added something
like this to MyDecimal __init__:

Decimal.__init__(self, str(value))

But I'm unfamiliar with the __new__ protocol.

Jeff Bauer
Rubicon, Inc.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing Decimal

2005-02-21 Thread [EMAIL PROTECTED]
STeVe,

Thanks for the response.  Very clear.

yea-though-I-walk-thru-the-valley-of-__new__-I-will-fear-no-super-ly
y'rs,

-Jeff

-- 
http://mail.python.org/mailman/listinfo/python-list