Activating `-i' from inside a script?
troy at gci.net
Fri Jun 27 08:09:44 CEST 2003
>> Is there a way for a script to activate the effect of the `-i' option,
> something like this might work:
> if discrepancy and sys.stdin.isatty():
> import code; code.interact(local=globals())
I thought this would work, but it doesn't:
if __name__ == '__main__':
discrepancy = True
os.environ['PYTHONINSPECT'] = "why yes, i'd like that"
A quick read of Modules/main.c shows that the environment variable is
checked at program start, not at end. Maybe this is a bug?
More information about the Python-list