Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'memory.': 0.05; 'rewrite': 0.07; 'subject:question': 0.08; 'api': 0.09; 'be:': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subclass': 0.09; '~ethan~': 0.09; 'aug': 0.13; 'iterator': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'subject:API': 0.16; 'martin': 0.16; 'wrote:': 0.17; 'implementing': 0.17; 'memory': 0.18; 'bit': 0.21; 'do.': 0.21; 'fairly': 0.21; 'work,': 0.22; 'cc:2**0': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'realize': 0.27; 'streaming': 0.27; 'loads': 0.29; 'question:': 0.29; 'maybe': 0.29; 'code': 0.31; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'list': 0.35; 'pm,': 0.35; 'table': 0.35; 'but': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'fact': 0.38; 'object': 0.38; 'possible.': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'easy': 0.60; 'skip:u 10': 0.60; 'back': 0.62; 'more': 0.63; 'received:67.18': 0.65; 'furman': 0.84; 'to:name:python': 0.84; 'ethan': 0.91 Date: Mon, 06 Aug 2012 08:40:53 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Python Subject: Re: dbf.py API question References: <501AA304.3090000@stoneleaf.us> <501E7EA2.1060408@stoneleaf.us> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.10.136]) [72.11.125.166]:3968 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344267374 news.xs4all.nl 6882 [2001:888:2000:d::a6]:51090 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26624 [redirecting back to list] Ole Martin Bjørndalen wrote: > On Sun, Aug 5, 2012 at 4:09 PM, Ethan Furman wrote: >> Ole Martin Bjørndalen wrote: >> You can do this by implementing either __getitem__ or __iter__, unless the >> streaming flag would also make your table not in memory. > > Cool! > > Wow! I realize now that this could in fact be fairly easy to > implement. I just have to shuffle around the code a bit to make both > possible. The API would be: > > # Returns table object which is a subclass of list > table = dbfget.read('cables.dbf') > for rec in table: > print rec > > # Return a table object which behaves like an iterator > table = dbfget.read('cables.dbf', iter=True) > for rec in table: > print rec > > I have a lot of questions in my mind about how to get this to work, > but I feel like it's the right thing to do. I will make an attempt at > a rewrite and get back to you all later. > > One more API question: I am uncomfortable with: > > > dbfget.read() > > Should it just be: > > dbfget.get() > > ? > > - Ole `dbfget` is the package name, and `read()` or `get` is the class/function that loads the table into memory and returns it? Maybe `load()`? ~Ethan~