On Feb 14, 11:06 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> It depends on what you mean by "an interactive shell"? If you start your
> script with:
> python -i whatever.py
> is it an interactive shell or not?
>
> I tried these two criteria:
> a) See if the __main__ module has a __file__ attribute.
> b) See if sys.stdin is a real tty

Right, so my idea of an 'interactive shell' seems to be a little ill
defined. Nonetheless, looking if the main module has a file attribute
looked to be a good idea until I tried it on IPython - returns True...

I think I'll do what I said in the first post, but add an option to
override the behaviour for less usual circumstances. Seems to be the
best compromise.

Dan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to