Proposal: Decimal literals in Python.

Shane Geiger sgeiger at ncee.net
Fri Oct 26 15:01:33 EDT 2007


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
sgeiger at ncee.net  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sgeiger.vcf
Type: text/x-vcard
Size: 288 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20071026/d11cdd62/attachment.vcf>


More information about the Python-list mailing list