Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Makes sense. I guess what I was getting at is that introducing Decimal to the example about f-string interpolation makes the example more complicated than it absolutely needs to be, but I can see why they did it.


I think some of that extra complexity could be papered over with either making decimal() available like int() and float(), which would eliminate the import, and/or implementing a decimal literal format, such as 0d2.675, analogous to the format of Hexadecimal and Octal literals (0xCC00CC and 0o267, respectively).


I like that second idea, perhaps a mention on the python-ideas mailing list?


Perhaps. I need to mull it over a bit before I take that plunge (but thank you for the encouragement!).

One possible objection is that while Decimal is in the standard library, it isn't a built-in type, so either Decimals need to be elevated to built-ins, or some magic needs to happen when importing the decimal module to add the literal.


They used Decimal just to show the nested attribute access




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: