On Wed, Jan 08, 2003 at 12:34:51PM +0100, Andre Poenitz wrote:
> 
> len(foo) doesn't work:
> 
> (My first shot at python!)
> 
> def change_preamble(lines):
>       for line in lines:
>               words = string.split(line)
>               if len(words) > 2:
>                       if [ "\\oddsidemargin", "\\evensidemargin", "\\marginparwidth",
>                               "\\textwidth", "\\topmargin", 
>"\\textheight"].count(words[0]) != 0:
>                               len = words[1] + words[2]
                                ^^^^
If you assign a value to the builtin len function, bad things will happen...

Also, the line
    if [ "\\oddsidemargin", ...].count(words[0]) != 0:
can be replace by
    if words[0] in ["\\oddsidemargin", ...]

However, it is probably better to use search&replace of regular expressions.

Reply via email to