4 ms·
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 ab
by vosper 10y ago
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.
- webmaven 10y agoI 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).
- mixmastamyk 10y agoI like that second idea, perhaps a mention on the python-ideas mailing list?
- webmaven 10y agoPerhaps. 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.
- renzon 10y agoThey used Decimal just to show the nested attribute access