[Top][All Lists]

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

Re: Corrected patch to convert-ly

From: Han-Wen Nienhuys
Subject: Re: Corrected patch to convert-ly
Date: Mon, 5 Aug 2002 00:39:21 +0200

address@hidden writes:
> 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 was trying to give a hint, not an exact solution.  In my
recollection, convert-ly was line based, but now it is longer, the
above idea won't work completely.  More hints

* re.match () always matches the beginning of the string, you want ().

* the re would be r"breakAlignOrder *= *#'\(([a-z_A-Z ]+)\)"

* the func would then be

  def func(match):
     props = ()
     # .. apply subst.
     return  "breakAlignOrder = #'( %s )" % props
  str = re.sub (r"breakAlignOrder *= *#'\(([a-z_A-Z ]+)\)", func, str)

Please try again, I _really_, _really_ prefer code that is tight.

> 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.

I think you're the only one that needs to convert breakAlignOrder. Not
many people use it.

Han-Wen Nienhuys   |   address@hidden   | 

reply via email to

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