How to tell if I'm being run from a shell or a module
Sion Arrowsmith
siona at chiark.greenend.org.uk
Fri Feb 15 06:17:03 EST 2008
Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
>a) See if the __main__ module has a __file__ attribute.
>b) See if sys.stdin is a real tty
c) See if sys.argv[0] != ''
(Although this works for the command line interactive shell, I've a
suspicion it will fail with IDLE. But I don't have IDLE to hand to
check.)
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list