[Python-ideas] User-defined literals
p.f.moore at gmail.com
Fri Jun 5 17:55:40 CEST 2015
On 5 June 2015 at 16:45, Andrew Barnert <abarnert at yahoo.com> wrote:
> So, what does "literal" mean, if it's neither the same thing as "compile-time" nor the same thing as "constant" but just happens to overlap those perfectly in the simplest cases? Well, I think the sense in which these things should "act like literals" is intuitively obvious, but very hard to nail down precisely. Hence the intentionally vague "sufficiently simple" definition I gave. But it doesn't _need_ to be nailed down precisely, because a proposal can be precise, and you can then check it against the cases people intuitively want, and see if they do the right thing.
OK, my apologies, we're basically agreeing violently, then.
IMO, people typically *actually* want a nicer syntax for Decimal
values known at source-code-writing time. They probably don't actually
really think much about whether the value could be affected by
monkeypatching, or runtime changes, because they won't actually do
that in practice. So just documenting a clear, sane and suitably
Pythonic behaviour should be fine in practice (it won't stop the
bikeshedding of course :-)) And "it's the same as Decimal('1.2')" is
likely to be sufficiently clear, sane and Pythonic, even if it isn't
actually a "literal" in any real sense. That's certainly true for me -
I'd be happy with a syntax that worked like that.
More information about the Python-ideas