Imported or executed?

Stephan Schulz schulz at sunbroy2.informatik.tu-muenchen.de
Wed Feb 16 14:04:57 EST 2005


Hi All,

I've written a Python replacement of fixbb, as shell/awk script that
will create tightly fitting bounding boxes for PostScript files.

Most of the functionality is encapsulated in a small function called
fixbb(filename). I'm importing this into other code via 'import'.

A few lines of code for command line handling make the module into a
freestanding program. For simplicity and ease of maintenance, I would
rather keep library and program as a single file.

However, the command line code is also executed when the module is
imported, not only when the stand-alone program is executed. That is
not, of course, intended (or working). 

Is there a (portable, standard) way for the program/module to find out
if it is imported or executed stand-alone?

You can find the code at
http://www.eprover.org/SOFTWARE/utilities.html

Bye,

    Stephan

-- 
-------------------------- It can be done! ---------------------------------
   Please email me as schulz at informatik.tu-muenchen.de (Stephan Schulz)
----------------------------------------------------------------------------



More information about the Python-list mailing list