[Python-ideas] Custom string prefixes

Andrew Barnert abarnert at yahoo.com
Thu May 30 23:03:47 CEST 2013


On May 30, 2013, at 13:15, goktug.kayaalp at gmail.com (Göktuğ Kayaalp) wrote:

>> Of course the OP wasn't even worried about that; he just wanted to
>> save a few keystrokes making decimals.
> 
> I haven't used the decimal library for anything other than the example
> I've given in the first post of this thread.  What I wanted was a more
> convenient way to express transformations on string literals that are
> usually expressed via functions and classes and what I proposed was a
> method to achieve this utilizing syntactic sugar and runtime evaluation
> of string literals.  Reducing my *worries* to an *effort of mutating the
> language to save some keystrokes* is rude.

But that's exactly what it is. Whether its just for Decimal, or for a wide variety of different constructors and function calls, it saves literally two keystrokes for each use (or maybe 3, if your functions need raw strings). I don't see why it's rude to point that out, or how it's not obviously true.

That doesn't mean it's necessarily a bad idea. As I said earlier, if there are application domains (numerics, XML processing, django, whatever) where a particular prefix would be of widespread use in making everyone's code more readable within that community, even though those prefixes wouldn't be used outside the community, your proposal might be a good idea. But it's still true that all it does is save a few keystrokes.

Meanwhile, the further suggestion by Haoyi and others to move things to compile time makes it a very different idea (especially since you explicitly asked for runtime evaluation), with different pros and cons. And that's what I was pointing out.


More information about the Python-ideas mailing list