Passing options to Python executable in non-interactive mode

后端 未结 4 883
故里飘歌
故里飘歌 2021-01-21 04:09

I would like to pass some options to Python (version 2.6) every time, not just in interactive mode. Is there a file I can put such commands in?

EDIT: Specifically, I\'m

4条回答
  •  逝去的感伤
    2021-01-21 04:48

    Have you tried ~/.pythonrc.py? It is listed in the Python man page with the following description:

    User-specific initialization file loaded by the user module; not used by default or by most applications.

    I'm not sure what it means by the 'user' module but I think it's worth a shot to try this.

    EDIT: It looks like you have to import user in your python scripts and then Python will automatically execute this ~/.pythonrc.py file upon startup (and not just in interactive mode). This should work in Python version < 3.0. http://docs.python.org/library/user.html

提交回复
热议问题