lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: backslashes in escape rules


From: John Mandereau
Subject: Re: backslashes in escape rules
Date: Sat, 05 Jul 2008 09:51:36 +0200

On 2008/07/04 17:38 -0700, Graham Percival wrote:
> Quick check for convert rules, changing "\foo" to "\bar".
> 
>    The early rules use escape chars:
> @rule ((1, 0, 1), '\\accidentals -> \\keysignature,
> specialaccidentals -> keyoctaviation')
> def conv (str):
>     str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
> 
>   But the later rules don't use any backslashes:
> @rule ((2, 11, 48), "\\compressMusic -> \\scaleDurations")
> def conv (str):
>     str = re.sub (r"compressMusic", r"scaleDurations", str)
>     return str
> 
> 
> Which should I use?  "foo", "\\foo", or "\\\\foo" ?

I guess the motivation for using "foo" iso. "\\\\foo" for regexp
substitution is making docs updating easier, as running text or comments
sometimes mention the command name without the backslash.

However, it's good to use "\\foo" (or r"\foo") in the rule description
that is printed when you do 'convert-ly -s'.

Cheers,
John





reply via email to

[Prev in Thread] Current Thread [Next in Thread]