Content-Length: 291236 | pFad | https://github.com/python/cpython/commit/82666c77e57d6e841b9bb1992689fb7f0889cb12

CE Clarify module.__file__ documentation · python/cpython@82666c7 · GitHub
Skip to content

Commit 82666c7

Browse files
RaghuRaghunandanKumar
authored andcommitted
Clarify module.__file__ documentation
1 parent a7d5a6c commit 82666c7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Doc/reference/datamodel.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,8 @@ this approach.
10731073

10741074
.. attribute:: module.__file__
10751075

1076-
:attr:`!__file__` is an optional attribute that
1077-
may or may not be set. Both attributes should be a :class:`str` when they
1078-
are available.
1076+
:attr:`!__file__` is an optional attribute that may or may not be set.
1077+
When it is set, it should be a :class:`str`.
10791078

10801079
An optional attribute, :attr:`!__file__` indicates the pathname of the file
10811080
from which the module was loaded (if loaded from a file), or the pathname of
@@ -1084,6 +1083,9 @@ this approach.
10841083
modules that are statically linked into the interpreter, and the
10851084
:ref:`import system <importsystem>` may opt to leave it unset if it
10861085
has no semantic meaning (for example, a module loaded from a database).
1086+
For modules loaded from a file by the import system, it is usually an
1087+
absolute path. However, other loaders may set it to a different value, so
1088+
code that needs an absolute path should normalize it explicitly.
10871089

10881090
.. deprecated-removed:: 3.13 3.15
10891091
Setting ``__cached__`` on a module while failing to set

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/commit/82666c77e57d6e841b9bb1992689fb7f0889cb12

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy