[Python-ideas] frozenset literals

Nick Coghlan ncoghlan at gmail.com
Sat Feb 2 15:56:57 CET 2013


On 3 Feb 2013 00:39, "Antoine Pitrou" <solipsis at pitrou.net> wrote:
>
> On Sun, 3 Feb 2013 00:28:55 +1000
> Nick Coghlan <ncoghlan at gmail.com> wrote:
> > FWIW, I could personally tolerate the introduction of s{} and fs{}
> > literals. We'd just declare the "s" prefix optional for non-empty sets
to
> > match the current rules.
> >
> > Encouraging the use of ast.literal_eval() over the security nightmare
that
> > is eval() would be more than enough justification for me. (As a syntax
> > change, the idea would still need a PEP, though)
>
> If it is enough of a justification, then why not literal support for
> more useful datatypes (decimal, datetime...) rather than frozenset?

The difference is that decimal and datetime already have safe "from string"
conversion operations. The empty set and frozen sets do not.

That said, a decimal literal proposal would be a reasonable follow-up to
the incorporation of cdecimal.

Datetime is a more difficult prospect, since there are good reasons
strptime is as flexible as it is.

Regardless, I'm not saying a PEP to support all the builtin container types
in ast.literal_eval would necessarily be accepted. I'm merely saying it is
*worth writing*.

Cheers,
Nick.

>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130203/6ec770f6/attachment.html>


More information about the Python-ideas mailing list