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
4ac00503
Kaydet (Commit)
4ac00503
authored
Agu 10, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
revamped somewhat
üst
3e7a697c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
anydbm.py
Lib/anydbm.py
+19
-18
No files found.
Lib/anydbm.py
Dosyayı görüntüle @
4ac00503
"""
A g
eneric interface to all dbm clones.
"""
G
eneric interface to all dbm clones.
Instead of
import dbm
d = dbm.open(file, '
r
w', 0666)
d = dbm.open(file, 'w', 0666)
use
import anydbm
d = anydbm.open(file)
The returned object is a db
m, gdbm or (on the Mac) dbmac
object,
The returned object is a db
hash, gdbm, dbm or dumbdbm
object,
dependent on availability of the modules (tested in this order).
It has the following interface (key and data are strings):
...
...
@@ -25,26 +25,27 @@ It has the following interface (key and data are strings):
list = d.keys() # return a list of all existing keys (slow!)
Future versions may change the order in which implementations are
tested for existence, add interfaces to other db
-like implementations
(e.g. BSD Hash)
, and (in the presence of multiple implementations)
tested for existence, add interfaces to other db
m-like
implementations
, and (in the presence of multiple implementations)
decide which module to use based upon the extension or contents of an
existing database file.
The open function has an optional second argument. This can be set to
'r' to open the database for reading only.
Don't pas an explicit 'w'
or 'rw' to open it for writing, as the different interfaces have
different interpretation of their mode argument if it isn't 'r'.
'r' to open the database for reading only.
The default is 'w', which
differs from the dbm default ('r') for historic reasons.
"""
try
:
import
dbm
def
open
(
filename
,
mode
=
'rw'
):
return
dbm
.
open
(
filename
,
mode
,
0666
)
except
ImportError
:
_names
=
[
'dbhash'
,
'gdbm'
,
'dbm'
,
'dumbdbm'
]
for
_name
in
_names
:
try
:
import
gdbm
def
open
(
filename
,
mode
=
'w'
):
return
gdbm
.
open
(
filename
,
mode
,
0666
)
exec
"import
%
s; _mod =
%
s"
%
(
_name
,
_name
)
except
ImportError
:
import
dbmac
open
=
dbmac
.
open
continue
else
:
break
else
:
raise
ImportError
,
"no dbm clone found; tried
%
s"
%
_names
def
open
(
file
,
flag
=
'w'
,
mode
=
0666
):
return
_mod
.
open
(
file
,
flag
,
mode
)
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