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
b5a3d9be
Kaydet (Commit)
b5a3d9be
authored
Nis 22, 2015
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #24029: Document the name binding behavior for submodule imports.
üst
532af163
4e1f355c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
import.rst
Doc/reference/import.rst
+35
-0
NEWS
Misc/NEWS
+5
-0
No files found.
Doc/reference/import.rst
Dosyayı görüntüle @
b5a3d9be
...
...
@@ -468,6 +468,41 @@ import machinery will create the new module itself.
``
create_module
()``
is
not
.
Starting
in
Python
3.6
it
will
be
an
error
to
not
define
``
create_module
()``
on
a
loader
attached
to
a
ModuleSpec
.
Submodules
----------
When
a
submodule
is
loaded
using
any
mechanism
(
e
.
g
.
``
importlib
``
APIs
,
the
``
import
``
or
``
import
-
from
``
statements
,
or
built
-
in
``
__import__
()``)
a
binding
is
placed
in
the
parent
module
's namespace to the submodule object.
For example, if package ``spam`` has a submodule ``foo``, after importing
``spam.foo``, ``spam`` will have an attribute ``foo`` which is bound to the
submodule. Let'
s
say
you
have
the
following
directory
structure
::
spam
/
__init__
.
py
foo
.
py
bar
.
py
and
``
spam
/
__init__
.
py
``
has
the
following
lines
in
it
::
from
.
foo
import
Foo
from
.
bar
import
Bar
then
executing
the
following
puts
a
name
binding
to
``
foo
``
and
``
bar
``
in
the
``
spam
``
module
::
>>>
import
spam
>>>
spam
.
foo
<
module
'spam.foo'
from
'/tmp/imports/spam/foo.py'
>
>>>
spam
.
bar
<
module
'spam.bar'
from
'/tmp/imports/spam/bar.py'
>
Given
Python
's familiar name binding rules this might seem surprising, but
it'
s
actually
a
fundamental
feature
of
the
import
system
.
The
invariant
holding
is
that
if
you
have
``
sys
.
modules
[
'spam'
]``
and
``
sys
.
modules
[
'spam.foo'
]``
(
as
you
would
after
the
above
import
),
the
latter
must
appear
as
the
``
foo
``
attribute
of
the
former
.
Module
spec
-----------
...
...
Misc/NEWS
Dosyayı görüntüle @
b5a3d9be
...
...
@@ -36,6 +36,11 @@ Library
-
Issue
#
23887
:
urllib
.
error
.
HTTPError
now
has
a
proper
repr
()
representation
.
Patch
by
Berker
Peksag
.
Documentation
-------------
-
Issue
#
24029
:
Document
the
name
binding
behavior
for
submodule
imports
.
What
's New in Python 3.5.0 alpha 4?
===================================
...
...
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