D = lambda x: decimal.Decimal(str(x))

>> D(3.2)
Decimal("3.2")



Steven D'Aprano wrote:
> On Fri, 26 Oct 2007 19:19:46 +1000, Ben Finney wrote:
>
>   
>>> Of course we can intruduce a single character function name as an alias
>>> for the Decimal type constructor, but even then we have to use both
>>> parentheses and quotes for each and every decimal constant. We cannot
>>> make it shorter than D("12.34")
>>>       
>> Nor should we. A function or type name should be short but explicit, and
>> 'Decimal' is about as short as I'd want.
>>     
>
> You don't like str, int, float, list, set, dict, or bool?
>
> Or for that matter, enum
> http://www.python.org/dev/peps/pep-0354/
>
> *wink*
>
>
>   


-- 
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
url:http://www.ncee.net
version:2.1
end:vcard

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

Reply via email to