Skip to content

Instantly share code, notes, and snippets.

@28sui
Created May 22, 2016 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 28sui/80df6a025a20cfe4f9b90917b8ea16b0 to your computer and use it in GitHub Desktop.
Save 28sui/80df6a025a20cfe4f9b90917b8ea16b0 to your computer and use it in GitHub Desktop.
import string
print(string)
import os
import imp
(filepath,tempfilename) = os.path.split(os.__file__)
string=imp.load_source('string',filepath+'/string.py')
print(filepath)
print(string)
#result
<module 'string' from '/Volumes/nan/Desktop/string.py'>
/Volumes/nan/.pyenv/versions/3.5.1/lib/python3.5
<module 'string' from '/Volumes/nan/.pyenv/versions/3.5.1/lib/python3.5/string.py'>
<module 'string' from '/Volumes/nan/.pyenv/versions/3.5.1/lib/python3.5/string.py'>
/Volumes/nan/.pyenv/versions/3.5.1/lib/python3.5
<module 'string' from '/Volumes/nan/.pyenv/versions/3.5.1/lib/python3.5/string.py'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment