String changing on the fly

Paul McGuire ptmcg at austin.rr._bogus_.com
Wed Oct 20 14:41:45 EDT 2004


"John Hunter" <jdhunter at ace.bsd.uchicago.edu> wrote in message
news:mailman.5235.1098294536.5135.python-list at python.org...
> >>>>> "John" == John Hunter <jdhunter at nitace.bsd.uchicago.edu> writes:
>
>
> Continuing the fun, you can define a new python class that inherits
> from string, but overrides the "convert me to a string representation"
> method __str__ to evaluate itself in the context of the global
> variables
>
> import re
>
>
> class PerlString(str):

<snip>

How do you know the language was Perl?  Could be Tcl, which also uses the
'$' substitution form. (Although "T=100" would be written "set T 100" in
that case.)

-- Paul





More information about the Python-list mailing list