File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments