开发者

Detect how I run Python script

开发者 https://www.devze.com 2023-03-07 00:36 出处:网络
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 th

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

精彩评论

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