473,545 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gdbm objects not iterable?


Hi All,

gdbm objects have a "firstkey" and a "nextkey" method. So if I want
iterate through the keys (which I often do) then I have to do this:

def itergdbmkeys(gd bm_obj):
key = gdbm_obj.firstk ey()
if key is None:
raise StopIteration
yield key
while True:
key = gdbm_obj.nextke y(key)
if key is None:
raise StopIteration
yield key

Then I can do this:

for key in itergdbmkeys(gd bm_obj):
process(key,gdb m_obj)

I wonder why we do not have a "next()" method, which could return an
iterator instantly. I don't think that it would be harmful, but
definitely it would be useful. Then we could do this:

for key in gdbm_obj:
process(key,obj )

I know that this is a very small change, but it can make gdbm objects
look more like dictionaries.

Please make comments. :-)

Laszlo

Oct 3 '07 #1
0 868

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1768
by: brokow | last post by:
I have been trying to get the gdbm module in python 2.4 to read a gdbm file from python 1.5.2 and having no luck. I get a file error when I try to open the 1.5.2-created gdbm file. Even a very simple gdbm database causes the trouble. E.g. I create a one-entry db in python 1.5.2 Python 1.5.2 (#0, Apr 13 1999, 10:51:12) on win32 Copyright...
2
1221
by: Shriphani | last post by:
dictionary = gdbm.open('dictionary','c') dictionary = 'Openbox' dictionary.get('Ellipsize') the last line generates an attribute error. Can someone tell me what I am doing wrong? Regards, Shriphani Palakodety
0
1024
by: Douglas Applegate | last post by:
Hi- I am having a problem with shelve. The problem I think is really with gdbm. I'll write out a file using shelve/gdbm on an amd64 machine and then I'll try to read it in on a i386 machine. The result is a 'gdbm fatal: read error.' Reversing directions results in the same problem. Below are two small programs that get at the heart of the...
4
1887
by: vshenoy | last post by:
Hi Guys, I was going through gdbm-1.8.3 source (http://ftp.gnu.org/gnu/gdbm/ gdbm-1.8.3.tar.gz) and found this strange thing : all the exposed functions of gdbm work with GDBM_FILE pointer (which is returned by gdbm_open), but in the implementation of gdbm functions (e.g. gdbm_open in gdbmopen.c)work with a structure called gdbm_file_info....
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.