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
0e1d6061
Kaydet (Commit)
0e1d6061
authored
Eki 08, 2007
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Better variable names
üst
b6893f2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
collections.py
Lib/collections.py
+4
-4
No files found.
Lib/collections.py
Dosyayı görüntüle @
0e1d6061
...
...
@@ -30,7 +30,7 @@ def NamedTuple(typename, field_names, verbose=False):
# Parse and validate the field names
if
isinstance
(
field_names
,
basestring
):
field_names
=
s
.
replace
(
','
,
' '
)
.
split
()
# names separated by spaces
and/or commas
field_names
=
field_names
.
replace
(
','
,
' '
)
.
split
()
# names separated by whitespace
and/or commas
field_names
=
tuple
(
field_names
)
if
not
''
.
join
((
typename
,)
+
field_names
)
.
replace
(
'_'
,
''
)
.
isalnum
():
raise
ValueError
(
'Type names and field names can only contain alphanumeric characters and underscores'
)
...
...
@@ -60,12 +60,12 @@ def NamedTuple(typename, field_names, verbose=False):
print
template
# Execute the template string in a temporary namespace
m
=
dict
(
itemgetter
=
_itemgetter
)
namespace
=
dict
(
itemgetter
=
_itemgetter
)
try
:
exec
template
in
m
exec
template
in
namespace
except
SyntaxError
,
e
:
raise
SyntaxError
(
e
.
message
+
':
\n
'
+
template
)
result
=
m
[
typename
]
result
=
namespace
[
typename
]
# For pickling to work, the __module__ variable needs to be set to the frame
# where the named tuple is created. Bypass this step in enviroments where
...
...
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