Python Gotcha's?

rusi rustompmody at gmail.com
Fri Apr 6 11:31:04 EDT 2012


On Apr 6, 7:18 pm, Grzegorz Staniak <gstan... at gmail.com> wrote:
> On 06.04.2012, Steven D'Aprano <steve+comp.lang.pyt... at pearwood.info> wroted:
>
> >> Are there languages (other than python) in which single and double
> >> quotes are equivalent?
>
> > Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML,
> > and (of course) English. There may be others.
>
> > Other languages like Perl, PHP and Ruby support alternate delimiters with
> > slightly different semantics.
>
> Perl, first of all, has the 'q' and 'qq' operators. As much as I'd
> come to dislike Perl after I discovered Python, I miss those two.
> Every time I have to quote a string full of single/double quotes,
> this comes to my mind:
>
>     q{'this' is not this, but 'that' is 'that' like 'this'}
>     q|'this' is not this, but 'that' is 'that' like 'this'|
>     q<'this' is not this, but 'that' is 'that' like 'this'>
>
> ... with 'qq' providing the version with inerpolation. I could
> always find an arbitrary character for quoting that was _not_ present
> in the string, and so, most of the time, avoid quoting altogether.
> It was perhaps a bit too magical, but pruced very readable strings.

Yes the q of perl is qute and qlever.
Come to think of it its very sensible because it factors delimition
from quoting just as the () and ' do for lisp.



More information about the Python-list mailing list