(newbie) syntax problem compiling python scripts...

Krist van Besien krist at vanbesien.org
Wed Jun 7 08:59:11 EDT 2000


I'm trying to compile a script as follows:

% python
>>> from py_compile import *
>>> compile ('htmlformat.py')
and then I get:
>>> compile ('htmlformat.py')
inconsistent dedent
  File "htmlformat.py", line 520
    f = open('includefile')
                           ^
SyntaxError: invalid token     

The piece of offending code looks like this (it's a part of the mailman
package btw):

def MailmanLogo():
    t = Table(border=0, width='100%')
    if mm_cfg.CUSTOM_FOOTER:
        includefile = os.path.join(mm_cfg.TEMPLATE_DIR,
mm_cfg.CUSTOM_FOOTER)
        f = open(includefile)
        text = f.read()
        f.close()
        t.AddRow([text])      

If I copy the codesnippet into a seperate file everything compiles
alricht, but in the context of the complete source python somehow
refuses to accept the "open" token, as if the definition was fracebly
forgotten, or overridden or such (I'm wildly speculating here).

What's going on? How do I debug this? 

TIA 
Krist



--
Ing. Krist van Besien    | At work:            | At home:
Software Engineer        | krist at west.nl       | krist at vanbesien.org
West Consulting B.V.     | http://www.west.nl  | 
Delft, the Netherlands   | +31 (0)15 2191604   | +31 (0)6 50235002
--
Why do programmers get Halloween and Christmas mixed up?
Because OCT(31) == DEC(25)



More information about the Python-list mailing list