Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ''' module_origin2.py
- Where does a given module come from?
- use os.path.dirname(module.__file__)
- import the modules you want to check
- can be as simple as ...
- import pip
- print(pip)
- also ...
- import inspect
- help(inspect.getmodule) # under FILE
- print(inspect.getmodule(inspect.getmodule))
- or (under FILE)...
- import collections
- help(collections)
- '''
- import os
- import pip
- import pygame as pg
- import numpy as np
- def module_location(module_name):
- print(module_name)
- print(os.path.dirname(module_name.__file__))
- # testing ...
- module_location(os)
- module_location(pip)
- module_location(pg)
- module_location(np)
- ''' result with Python33 ...
- <module 'os' from 'C:\\Python33\\lib\\os.py'>
- C:\Python33\lib
- <module 'pip' from 'C:\\Python33\\lib\\site-packages\\pip\\__init__.py'>
- C:\Python33\lib\site-packages\pip
- <module 'pygame' from 'C:\\Python33\\lib\\site-packages\\pygame\\__init__.py'>
- C:\Python33\lib\site-packages\pygame
- <module 'numpy' from 'C:\\Python33\\lib\\site-packages\\numpy\\__init__.py'>
- C:\Python33\lib\site-packages\numpy
- '''
Advertisement
Add Comment
Please, Sign In to add comment