Parsing data from pyserial

John Machin sjmachin at lexicon.net
Sun Dec 3 13:40:54 EST 2006


Grant Edwards wrote:

> When something odd seems to be happening with strings, always
> print `whatever` rather than whatever
>

:-)

Unholy perlism, Batman!

For the benefit of gentle readers who are newish and might not have
seen the ` character in Python code outside a string literal, or for
those who'd forgotten, there is a cure:

| >>> re.sub(r"`(.*?)`", r"repr(\1)", "print `whatever`, `foo`, `bar`")
| 'print repr(whatever), repr(foo), repr(bar)'


:-)




More information about the Python-list mailing list