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
d331ce9e
Kaydet (Commit)
d331ce9e
authored
Agu 08, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9507: Named tuple repr will now automatically display the right
name in a tuple subclass.
üst
a6b76ba5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
2 deletions
+15
-2
collections.rst
Doc/library/collections.rst
+1
-1
collections.py
Lib/collections.py
+1
-1
test_collections.py
Lib/test/test_collections.py
+10
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
d331ce9e
...
@@ -605,7 +605,7 @@ Example:
...
@@ -605,7 +605,7 @@ Example:
<BLANKLINE>
<BLANKLINE>
def __repr__(self):
def __repr__(self):
'Return a nicely formatted representation string'
'Return a nicely formatted representation string'
return
'Point
(x=%r, y=%r)' % self
return
self.__class__.__name__ + '
(x=%r, y=%r)' % self
<BLANKLINE>
<BLANKLINE>
def _asdict(self):
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
'Return a new OrderedDict which maps field names to their values'
...
...
Lib/collections.py
Dosyayı görüntüle @
d331ce9e
...
@@ -240,7 +240,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
...
@@ -240,7 +240,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
return result
\n
return result
\n
def __repr__(self):
def __repr__(self):
'Return a nicely formatted representation string'
'Return a nicely formatted representation string'
return
'
%(typename)
s
(
%(reprtxt)
s)'
%%
self
\n
return
self.__class__.__name__ + '
(
%(reprtxt)
s)'
%%
self
\n
def _asdict(self):
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self))
\n
return OrderedDict(zip(self._fields, self))
\n
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
d331ce9e
...
@@ -218,6 +218,16 @@ class TestNamedTuple(unittest.TestCase):
...
@@ -218,6 +218,16 @@ class TestNamedTuple(unittest.TestCase):
# test __getnewargs__
# test __getnewargs__
self
.
assertEqual
(
t
.
__getnewargs__
(),
values
)
self
.
assertEqual
(
t
.
__getnewargs__
(),
values
)
def
test_repr
(
self
):
with
support
.
captured_stdout
()
as
template
:
A
=
namedtuple
(
'A'
,
'x'
,
verbose
=
True
)
self
.
assertEqual
(
repr
(
A
(
1
)),
'A(x=1)'
)
# repr should show the name of the subclass
class
B
(
A
):
pass
self
.
assertEqual
(
repr
(
B
(
1
)),
'B(x=1)'
)
class
ABCTestCase
(
unittest
.
TestCase
):
class
ABCTestCase
(
unittest
.
TestCase
):
def
validate_abstract_methods
(
self
,
abc
,
*
names
):
def
validate_abstract_methods
(
self
,
abc
,
*
names
):
...
...
Misc/NEWS
Dosyayı görüntüle @
d331ce9e
...
@@ -24,6 +24,9 @@ Core and Builtins
...
@@ -24,6 +24,9 @@ Core and Builtins
Extensions
Extensions
----------
----------
- Issue #9507: Named tuple repr will now automatically display the right
name in a tuple subclass.
- Issue #9324: Add parameter validation to signal.signal on Windows in order
- Issue #9324: Add parameter validation to signal.signal on Windows in order
to prevent crashes.
to prevent crashes.
...
...
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