lilypond-devel
[Top][All Lists]
Advanced

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

Re: Corrected patch to convert-ly


From: Laura Conrad
Subject: Re: Corrected patch to convert-ly
Date: 04 Aug 2002 17:43:56 -0400
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

>>>>> "Han-Wen" == Han-Wen Nienhuys <address@hidden> writes:

    Han-Wen> address@hidden writes:
    >> This one works:

    Han-Wen> Yes, but I think your code is too verbose. 

But it's readable, compared with most stuff using the re module.

    Han-Wen>      str = re.sub ('(breakAlignOrder *= )*\([^)]+\)(.*)',
    Han-Wen>      func, str)

This being a good example of something not very readable.  Nor
writeable, since:

        matchobj = re.match ('(breakAlignOrder *= )*\([^)]+\)(.*)',
        str)

returns a matchobj of "None" when str comes from a file with some
breakAlignOrder groups.  And I have no idea how to figure out what's
wrong.

I don't understand the re example in "Learning Python", either, and
I've tried several times.

    Han-Wen>      def func(m):
    Han-Wen>     prop = m.group(2)
    Han-Wen>     # your substitution here
    Han-Wen>          return m.group(1) + prop + m.group (3)

This is going to have to become more verbose to deal with .ly files
with more than one breakAlignOrder.

Since convert-ly is in general a one-time thing, I would think
correctness was a better figure of merit than compactness.

I'm sure there's a more idiomatic to python way to write this, but if
it were that easy, someone would have written it by now.  I can't be
the only person who needs it to convert their 4.x code to 5.x.

-- 
Laura (mailto:address@hidden , http://www.laymusic.org/ )
(617) 661-8097  fax: (801) 365-6574 
233 Broadway, Cambridge, MA 02139




reply via email to

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