开发者

Detect how I run Python script

How do I detect if a script is run from a Windows console or fro开发者_StackOverflow中文版m Komodo debugger without passing different arguments to the script?


Although I don't know Komodo, I don't think its standard input is interactive, so you could try

import sys
in_console = sys.__stdin__.isatty()

in_console will then be true if the invoker provides interactive stdin and you will get what you want, though not in an elegant way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜