Last active
November 21, 2020 04:56
-
-
Save cdgriffith/e0d8692fc307cc46cfcda2d8c4edd562 to your computer and use it in GitHub Desktop.
Python RC file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In .bashrc and .profile | |
# export PYTHONSTARTUP="$HOME/.pythonrc.py" | |
# pip install python-box reusables pdir2 | |
from __future__ import print_function, with_statement, absolute_import | |
try: | |
from box import Box, BoxList | |
except ImportError: | |
print("Box not available") | |
try: | |
import reusables | |
from reusables.cli import * | |
except ImportError: | |
print("Reusables not available") | |
try: | |
import pdir | |
except ImportError: | |
print("pdir not available") | |
import os | |
import sys | |
print('Python {0} on {1}'.format(".".join(str(x) for x in sys.version_info[:3]), sys.platform)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just like a
.bashrc
file, you can have a.pythonrc
file that is called at startup on Python consoles.All the mentioned files are to go in
$HOME
and will require any active terminals to be restarted to take effect (or manuallysource
ed again).Each external library is in it's own try except, that way no matter which python environment we are running, we import as many as possible.