[Tutor] file attribute of module
Kermit Rose
kermit at polaris.net
Fri Jun 9 16:48:46 CEST 2006
Message: 2
Date: Thu, 08 Jun 2006 09:28:27 -0400
From: Kent Johnson <kent37 at tds.net>
Subject: Re: [Tutor] module versus file
Most modules do have corresponding files. The exceptions are the ones
built-in to Python. In fact modules have a __file__ attribute that tells
you where it came from; try typing
factor30.__file__
Kent
*******
>>> import factor30
>>> factor30._file_
Traceback (most recent call last):
File "<pyshell#2>", line 1, in -toplevel-
factor30._file_
AttributeError: 'module' object has no attribute '_file_'
>>>
>>> factor30.__file__
'c:\\math\\factoring\\factor30.py'
>>>
Ok. Now I understand it.
The module is named factor30.
The file is named factor30.py
I presume that if I created another library in the same directory
in a file named factor31.py
that it would create a module named factor31. ???
More information about the Tutor
mailing list