Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9aa00d1c
Kaydet (Commit)
9aa00d1c
authored
Mar 29, 2014
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19697: document more __main__.__spec__ quirks
üst
e08f376e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
import.rst
Doc/reference/import.rst
+16
-2
No files found.
Doc/reference/import.rst
Dosyayı görüntüle @
9aa00d1c
...
...
@@ -852,16 +852,30 @@ Depending on how :mod:`__main__` is initialized, ``__main__.__spec__``
gets
set
appropriately
or
to
``
None
``.
When
Python
is
started
with
the
:
option
:`-
m
`
option
,
``
__spec__
``
is
set
to
the
module
spec
of
the
corresponding
module
.
to
the
module
spec
of
the
corresponding
module
or
package
.
``
__spec__
``
is
also
populated
when
the
``
__main__
``
module
is
loaded
as
part
of
executing
a
directory
,
zipfile
or
other
:
data
:`
sys
.
path
`
entry
.
In
:
ref
:`
the
remaining
cases
<
using
-
on
-
interface
-
options
>`
``
__main__
.
__spec__
``
is
set
to
``
None
``:
``
__main__
.
__spec__
``
is
set
to
``
None
``,
as
the
code
used
to
populate
the
:
mod
:`
__main__
`
does
not
correspond
directly
with
an
importable
module
:
-
interactive
prompt
-
-
c
switch
-
running
from
stdin
-
running
directly
from
a
source
or
bytecode
file
Note
that
``
__main__
.
__spec__
``
is
always
``
None
``
in
the
last
case
,
*
even
if
*
the
file
could
technically
be
imported
directly
as
a
module
instead
.
Use
the
:
option
:`-
m
`
switch
if
valid
module
metadata
is
desired
in
:
mod
:`
__main__
`.
Note
also
that
even
when
``
__main__
``
corresponds
with
an
importable
module
and
``
__main__
.
__spec__
``
is
set
accordingly
,
they
're still considered
*distinct* modules. This is due to the fact that blocks guarded by
``if __name__ == "__main__":`` checks only execute when the module is used
to populate the ``__main__`` namespace, and not during normal import.
Open issues
===========
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment