On Mon, May 27, 2013 at 3:47 PM, Masklinn <masklinn@masklinn.net> wrote:
Regardless of the implementation details (which can be bikeshed
separately afterwards if the idea is considered worthy), there seem to
be 2 different suggestions in my reading:

1. Pluggable string prefixes allowing custom parsing of string literals
   and their resulting in arbitrary types, e.g. a `d` prefix on a string
   literal would yield a decimal.Decimal (one can also imagine an
   `h`-string for markup-safe strings literals[1] for instance)



For this specific use-case I'd suggest

    d = decimal.Decimal
    d('1.0')

 
2. Some sort of codegen/environment hook allowing (amongst other
   things?) the implementation of shell/ruby/perl string interpolation
   (Scala uses prefixes for interpolator specifications[2])

 
A friend of mine likes to do this:

    import sys
    '{sys}'.format(**locals())


Yuval Greenfield