[Tutor] Where is sys.py?

Emile van Sebille emile at fenx.com
Sun Aug 21 17:31:20 CEST 2011


On 8/21/2011 4:57 AM Lisi said...
> If sys.py is a file, it must be somewhere; but I can't find it.  Where is it?
> I would like to look at it.
>
> The modules within it must surely be somewhere too.  But since I can't find
> sys, I obviously can't find the modules.  Again, I'd like to look at them.
>
> In case it is relevant, I am using Python 2.5.2 on Debian 5.
>


Modules have a __file__ attribute, but not sys as you've heard.

Python 2.6.6 (r266:84292, May 25 2011, 09:51:06)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.__file__
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'
 >>> import os
 >>> os.__file__
'/usr/local/lib/python2.6/os.pyc'
 >>>



More information about the Tutor mailing list