Multiple equates

Cameron Laird claird at
Wed Dec 3 11:09:58 CET 2008

In article <gh5f7h$jqh$1 at>,
Lawrence D'Oliveiro  <ldo at geek-central.gen.new_zealand> wrote:
>Cameron Laird wrote:
>>        def f1(Match):
>>            return
>Something missing here?

Ugh; yes, sorry:

   def shell_escape(Arg) :
       """returns Arg suitably escaped for use as a command-line argument
       to Bash."""

       pattern = r"[\<\>\"\'\|\&\$\#\;\(\)\[\]\{\}\`\!\~\ \\]"
       def f1(Match):
	   return "\\" +
       return re.sub(pattern, f1, Arg)
             # Need to catch anything that might be meaningful to shell
   #end shell_escape

More information about the Python-list mailing list