[Python-ideas] Briefer string format

Andrew Barnert abarnert at yahoo.com
Mon Jul 20 07:18:47 CEST 2015

On Jul 19, 2015, at 21:58, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On 20 July 2015 at 14:46, Steve Dower <Steve.Dower at microsoft.com> wrote:
>> So, macros basically? The real ones, not #define.
>> What's wrong with special casing text strings (a little bit more than they
>> already have been)?
> I've wished for a cleaner shell command invocation syntax many more
> times than I've wished for easier string formatting, but I *have*
> wished for both. Talking to the scientific Python folks, they've often
> wished for a cleaner syntax to create deferred expressions with the
> full power of Python's statement level syntax.
> Explicitly named macros could deliver all three of those, without the
> downsides of implicit globally installed macros that are
> indistinguishable from regular syntax.

MacroPy already gives you macros that are explicitly imported, and explicitly marked on use, and nicely readable. And it already works, with no changes to Python, and it includes a ton of little features that you'd never want to add to core Python.

There are definitely changes to Python that could make it easier to improve MacroPy or start a competing project, but I think it would be more useful to identify and implement those changes than to try to build a macro system into Python itself. (Making it possible to work on the token level, or to associate bytes/text/tokens/trees/code with each other more easily, or to hook syntax errors and reprocess the bytes/text/tokens, etc. are some such ideas. But I think the most important stuff wouldn't be new features, but removing the annoyances that get in the way of trying to build the simplest possible new macro system from scratch for 3.5, and we probably can't know what those are until someone attempts to build such a thing.)

More information about the Python-ideas mailing list