DBF records API

Tim Chase python.list at tim.thechases.com
Sat Jun 2 15:20:31 CEST 2012


On 06/02/12 00:16, Ethan Furman wrote:
> Tim Chase wrote:
>> On 06/01/12 19:05, Jon Clements wrote:
>>> On 01/06/12 23:13, Tim Chase wrote:
>>>>    dbf.scatter_fields
>>>>
>>>> *always* trump and refer to the method.
>>> I did think about *trumping* one way or the other, but both *ugh*.
>>
>> For the record, it sounded like the OP wanted to be able to use the
>> dot-notation for accessing fields by name, and I think it's a pretty
>> non-pythonic way to do it.  I'd much rather just stick to purely
>> using __getitem__ for the fields and attributes/methods for non-fields.
> 
> It can't be *that* non-Pythonic -- we now have namedtuples which pretty 
> much behave just like my record class (although its indexes are only 
> numbers, not strings as well).

Right, but the contents of the named-tuple are usually static in
relation to the code itself, rather than dependent on external
factors (such as user-supplied DBF files).  In addition, I believe
namedtuple has methods prefixed by an underscore to stave off
clashing names.

-tkc






More information about the Python-list mailing list