Module __file__ attribute in Python 3

Diez B. Roggisch deets at
Fri Aug 29 19:11:45 CEST 2008

> That will mean that there will be no (easy?) way to determine after the
> import whether the module was imported from a source file or a compiled
> file. I've suggested that the original justification for the patch no
> longer applies, and that the secondary purpose of the patch is better
> solved by leaving __file__ as it is in Python 2.x, and introducing a new
> attribute __source__.
> What do people think? There seems to be a little interest on the python-
> dev list from a couple of people, but not enough to actually lead to any
> action. Does anyone care what m.__file__ is? Does anyone else feel that
> this issue is worth pursuing?

I'm +1 on this. Introducing __source__ shouldn't break anything, and is a
minor change as the mapping of loaded file to defining file is already


More information about the Python-list mailing list