[Compiler-sig] My code runs - but I can't 'compile' it... WHY?!

Michael Hudson mwh at python.net
Mon Aug 2 16:09:56 CEST 2004


"Phil Hornby" <phil.hornby at accutest.co.uk> writes:

>>> Hi out there...
>>
>> This isn't really a very good place to ask this question...
>
> Strange I would think that the Compiler SIG would deal with the compiler
> module - maybe I am missing something...

It's not a ridiculous assumption -- just an incorrect one!

(Well, it seems to have worked for you, so maybe it wasn't <wink>).

>>> The code runs fine from a command prompt but when I try to compile it 
>>> from an interactive session of the Python interpreter as below I get 
>>> the error shown... ANY IDEAS??
>>
>> Why are you using Lib/compiler and not py_compile?  But it's hard to say
> more without ... erm ... seeing some code.  
>> Maybe you can comment things out and use binary chop to find the syntax
> that is defeating Lib/compiler.  This would 
>> be interesting in itself as I thought I'd fixed all of those problems...
>
> Why an I using it - cos it was the first thing I came across when I type
> compile into a help search... Seemed a reasonable module to use...

Again, not silly, but wrong :-) You want to use py_compile (really).
This uses the builtin compiler to make .pyc files in a way that's very
similar to how it happens when you import the files.

The compiler package is most useful for compiling languages which are
similar to Python but not quite the same, like Quixote's PTL.

> I will try to have a play to see where the problem comes in 

Thanks!

> - could it be the fact that I use my own modules written in C?

Very, very unlikely

Cheers,
mwh

-- 
     ARTHUR:  Why are there three of you?
  LINTILLAS:  Why is there only one of you?
     ARTHUR:  Er... Could I have notice of that question?
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11


More information about the Compiler-sig mailing list