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]
                                words[1:3] = [len]
                                line = string.join(words)

yields:

Traceback (most recent call last):
  File "./lyx2lyx", line 183, in ?
    main(sys.argv)
  File "./lyx2lyx", line 176, in main
    __import__("lyxconvert_" + fmt).convert(header,body)
  File "./lyxconvert_220.py", line 102, in convert
    change_preamble(header)
  File "./lyxconvert_220.py", line 92, in change_preamble
    l = len(words)
UnboundLocalError: local variable 'len' referenced before assignment

What does that mean?

Andre'


-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)

Reply via email to