I have found most python modules in python source directory, under Python/Lib or Python/Modules ,but where is the sys (import sys) module ? I didn’t find it .
I have found most python modules in python source directory, under Python/Lib or Python/Modules
Share
The Answer
I find it here:
./Python/sysmodule.cIf you’re on Linux or Mac OS X, and in doubt, just try
find . -name 'sysmodule.c'in the Python directory.Other Stuff
The way I found it was by searching for the string
"platform"throughout the Python directory (using TextMate), as I’ve used e.g.sys.platformbefore from thesysmodule… something similar can be done withgrepandxargs.Another suggestion could be :
for i in ./**/*.c ; do grep -H platform $i ; doneThis will loop through all
*.cfiles present in anywhere up the file tree you’re currently located at, and search the file for"platform". The-Hflag will ensure we get a filename path so we can trace the matches back to the files they are found in.