[Python-Dev] Binary Operator for New-Style String Formatting

Antoine Pitrou solipsis at pitrou.net
Sun Jun 21 20:45:20 CEST 2009


Hello,

> For better or for worse, I have created a patch against the py3k trunk
> which introduces a binary operator '@' as an alternative syntax for
> the new string formatting system introduced by PEP 3101 ("Advanced
> String Formatting"). [1]

While many people find the new format() tedious to adapt to, I don't think
adding a third formatting syntax will help us.

Especially given this annoyance:

> Lastly, to print the repr() of a dictionary as an unnamed argument,
> one would have to append an additional dictionary so there is no
> ambiguity:
> 
>     >>> "{}" @ {"foo": "bar"}
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>     IndexError: tuple index out of range
> 
>     >>> "{}" @ ({"foo": "bar"}, {})
>     "{'foo': 'bar'}"

Regards

Antoine.




More information about the Python-Dev mailing list