[Tutor] Annoying problem when importing a file (caused by IDLE?)

Gregor Lingl glingl at aon.at
Tue Sep 13 01:15:58 CEST 2005


Hi pythonistas!

Recently I've encountered a very annoying problem when developing a 
program - more exactly a module - of several hundred lines using Idle. 
Of course I have a __name__=="__main__" section to test my classes,
which ran successfully every time, (except when there were bugs :-( in 
the code. ;-) )

moreover I use several test programs, which import that module.
When running these I got (repeatedly after doing some modifications) 
syntax error - messages, pointing to randomly scattered positions in the 
module file. Only random-hacking like deliberately inserting spaces in 
some expressions or deleting empty lines or comment-lines solved this
problem, which tends to re-occur after some more changes.

1) Did anybody experience similar behaviour?

2) Can anybody *explain* how it comes, that a module as a program for 
itself runs without problems, while it doesn't when imported by another 
program instead delivering incomprehensable syntax error messages? This 
occurs in the same way when running them from the commandline and even 
on different computers (running WindowsXP as os.)

3) Probably my file is contaminated by some non printing characters - 
although I don't know where they come from. Is there a simple way to 
check this assumption (e.g. using some simple editor, which shows these
"unfriendly" characters.)

4) I urgently feel, that I have to stop these annoyances. Do you know 
how I can do this?

Desperately

Gregor



-- 
Gregor Lingl
Reisnerstrasse 3/19
A-1030 Wien

Telefon: +43 1 713 33 98
Mobil:   +43 664 140 35 27




More information about the Tutor mailing list