klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Here is one for the more advanced users

Mon Nov 28, 2016 4:23 pm

I would like to permanently import os into python3.
I did look/google for a python config file.
Is there either a config file or some other way to have some import loaded permanently?
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Here is one for the more advanced users

Mon Nov 28, 2016 4:38 pm

Have a look under "ENVIRONMENT VARIABLES" in the python man page.

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: Here is one for the more advanced users

Mon Nov 28, 2016 6:59 pm

I don't understand it says something about moving the library. I don't see how to load the import every time I bring up python3?
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
Paeryn
Posts: 2966
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Here is one for the more advanced users

Mon Nov 28, 2016 7:30 pm

For interactive python only you can set the environment variable PYTHONSTARTUP, that defines a file that will be run at startup before the 1st prompt is given. It won't be run when running programs though as it would probably break a lot of programs.
She who travels light — forgot something.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Here is one for the more advanced users

Tue Nov 29, 2016 9:24 am

klintkrossa wrote:I would like to permanently import os into python3.
I did look/google for a python config file.
Is there either a config file or some other way to have some import loaded permanently?
Another question is "why?". Firstly, it doesn't seem too hard to add an import line at the start of the script. Secondly, if someone else was to look at your code they wouldn't immediately know that os had been imported outside of the script. If they then tried to copy your script, it wouldn't work.

Don't get me wrong, I'm interested in the answers, I just don't necessarily think it's a good idea.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Return to “Python”