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 wanting to silence the Deprecation warnings.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
#!/usr/bin/pythonline at the beginning of a Python script under Linux can be used to also pass options to the interpreter.There are also a number of modules imported whenever Python starts up. On my system, a likely candidate for modification to set options in the manner suggested by other posters are here:
If you simply put this code in that file:
it will turn off deprecation warnings for everything always, which may not be what you want. You could instead put in code that would check your own
PYTHONNODEPRECATIONWARNINGenvironment variable so you had more control.After finding a reference to sitecustomize.py in Dive Into Python and this reference to the sitecustomize module in the Python 2.6 documentation, I think that file is your best bet for what you want. In Python 2.6, with its user specific site-packages directory it’s possible to set this up on a per-user basis, though you may want to find any system-wide sitecustomize.py file and either copy it into yours or find a way to explicitly import it in yours.