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
1d69a701
Kaydet (Commit)
1d69a701
authored
Tem 28, 2006
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Don't overwrite built-in name; add some blank lines for readability
üst
bd468103
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
libshelve.tex
Doc/lib/libshelve.tex
+3
-1
No files found.
Doc/lib/libshelve.tex
Dosyayı görüntüle @
1d69a701
...
@@ -143,15 +143,17 @@ data = d[key] # retrieve a COPY of data at key (raise KeyError if no
...
@@ -143,15 +143,17 @@ data = d[key] # retrieve a COPY of data at key (raise KeyError if no
del d[key] # delete data stored at key (raises KeyError
del d[key] # delete data stored at key (raises KeyError
# if no such key)
# if no such key)
flag = d.has
_
key(key) # true if the key exists
flag = d.has
_
key(key) # true if the key exists
list = d.keys() # a list of all existing keys (slow!)
k
list = d.keys() # a list of all existing keys (slow!)
# as d was opened WITHOUT writeback=True, beware:
# as d was opened WITHOUT writeback=True, beware:
d['xx'] = range(4) # this works as expected, but...
d['xx'] = range(4) # this works as expected, but...
d['xx'].append(5) # *this doesn't!* -- d['xx'] is STILL range(4)!!!
d['xx'].append(5) # *this doesn't!* -- d['xx'] is STILL range(4)!!!
# having opened d without writeback=True, you need to code carefully:
# having opened d without writeback=True, you need to code carefully:
temp = d['xx'] # extracts the copy
temp = d['xx'] # extracts the copy
temp.append(5) # mutates the copy
temp.append(5) # mutates the copy
d['xx'] = temp # stores the copy right back, to persist it
d['xx'] = temp # stores the copy right back, to persist it
# or, d=shelve.open(filename,writeback=True) would let you just code
# or, d=shelve.open(filename,writeback=True) would let you just code
# d['xx'].append(5) and have it work as expected, BUT it would also
# d['xx'].append(5) and have it work as expected, BUT it would also
# consume more memory and make the d.close() operation slower.
# consume more memory and make the d.close() operation slower.
...
...
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