[Python-ideas] Draft PEP on string interpolation

Mike Miller python-ideas at mgmiller.net
Mon Aug 24 23:59:06 CEST 2015


On 08/24/2015 02:29 PM, Wes Turner wrote:
>
> * How do I overload/subclass [class estr()]?

     class wes_estr(estr):
         pass

> * Does it always just read LC_ALL='utf8' (or where do I specify that
> global/thread/frame-local?)

    No, I just chose that in my script to show it suppoorted str functionality 
for example, .encode('utf-8'), it is not otherwise related to estr.

I should post the script.

> * How do I escape_func?

You pass in a function that does the escaping.

> Jinja2 uses MarkupSafe, with a class named Markup:
>
>     class Markup():
>          def __html__()
>          def __html_format__()

By letting the caller set the escaping rules via passed function, estr does not 
have to know anything about escaping, and is much simpler.  Also the caller 
could its own escaping rules.

-Mike



More information about the Python-ideas mailing list