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
4e0172fd
Kaydet (Commit)
4e0172fd
authored
May 18, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecate nametuple._asdict()
üst
8c03d832
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
collections.rst
Doc/library/collections.rst
+5
-2
__init__.py
Lib/collections/__init__.py
+3
-0
test_collections.py
Lib/test/test_collections.py
+5
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
4e0172fd
...
...
@@ -829,6 +829,9 @@ field names, the method and attribute names start with an underscore.
.. versionchanged:: 3.1
Returns an :class:`OrderedDict` instead of a regular :class:`dict`.
.. deprecated:: 3.4
Use ``vars(nt)`` or ``nt.__dict__`` instead.
.. method:: somenamedtuple._replace(kwargs)
Return a new instance of the named tuple replacing specified fields with new
...
...
@@ -845,8 +848,8 @@ field names, the method and attribute names start with an underscore.
A string with the pure Python source code used to create the named
tuple class. The source makes the named tuple self-documenting.
It can be printed, executed using :func:`exec`,
or saved to a file
and imported.
It can be printed, executed using :func:`exec`,
customized, or saved
to a file
and imported.
.. versionadded:: 3.3
...
...
Lib/collections/__init__.py
Dosyayı görüntüle @
4e0172fd
...
...
@@ -280,6 +280,9 @@ class {typename}(tuple):
'''Return a new OrderedDict which maps field names to their values.
This method is obsolete. Use vars(nt) or nt.__dict__ instead.
'''
import warnings
warnings.warn('_asdict() is deprecated. Use vars(nt) instead.',
DeprecationWarning, stacklevel=2)
return self.__dict__
def __getnewargs__(self):
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
4e0172fd
...
...
@@ -217,8 +217,11 @@ class TestNamedTuple(unittest.TestCase):
self
.
assertEqual
(
p
,
Point
.
_make
([
11
,
22
]))
# test _make classmethod
self
.
assertEqual
(
p
.
_fields
,
(
'x'
,
'y'
))
# test _fields attribute
self
.
assertEqual
(
p
.
_replace
(
x
=
1
),
(
1
,
22
))
# test _replace method
self
.
assertEqual
(
p
.
_asdict
(),
dict
(
x
=
11
,
y
=
22
))
# test _asdict method
self
.
assertEqual
(
vars
(
p
),
p
.
_asdict
())
# verify that vars() works
self
.
assertEqual
(
p
.
__dict__
,
OrderedDict
([(
'x'
,
11
),
(
'y'
,
22
)]))
# test __dict__ attribute
self
.
assertEqual
(
vars
(
p
),
p
.
__dict__
)
# verify that vars() works
with
self
.
assertWarns
(
DeprecationWarning
):
# check deprecate of _asdict
p
.
_asdict
()
try
:
p
.
_replace
(
x
=
1
,
error
=
2
)
...
...
Misc/NEWS
Dosyayı görüntüle @
4e0172fd
...
...
@@ -96,6 +96,9 @@ Library
- Issue #15758: Fix FileIO.readall() so it no longer has O(n**2) complexity.
- Deprecated the _asdict() method on named tuples. Use __dict__ or vars(nt)
instead.
- Issue #14596: The struct.Struct() objects now use more compact implementation.
- Issue #17981: Closed socket on error in SysLogHandler.
...
...
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