Re: API design question for dbf.py
On 06/07/2012 22:34, Ethan Furman wrote: I'm looking for some free advice. ;) My dbf module has three basic containers, all of which support list-like access: Table, List, and Index, each of which is filled with _DbfRecords. The fun part is that a _DbfRecord can compare equal to another _DbfRecord, a _DbfRecordTemplate, a tuple with the same values in the same locations, or a dict with the same keys/fields and values. The really fun part is __contains__: should the __contains__ method return True when a _DbfRecordTemplate, tuple, or dict is looked up in the Table, List, or Index and there is a matching record? Well, if x is in c and x == y, then y is in c. Does that help? ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: API design question for dbf.py
MRAB wrote: On 06/07/2012 22:34, Ethan Furman wrote: I'm looking for some free advice. ;) My dbf module has three basic containers, all of which support list-like access: Table, List, and Index, each of which is filled with _DbfRecords. The fun part is that a _DbfRecord can compare equal to another _DbfRecord, a _DbfRecordTemplate, a tuple with the same values in the same locations, or a dict with the same keys/fields and values. The really fun part is __contains__: should the __contains__ method return True when a _DbfRecordTemplate, tuple, or dict is looked up in the Table, List, or Index and there is a matching record? Well, if x is in c and x == y, then y is in c. Does that help? ;-) Heh, that's pretty much the conclusion I was coming to. As a more concrete example: -- x = 4.0 -- x in [1, 4, 7, 4, 9, 3, 4] True It's checking for equality, not identity. Thinks for helping me think that through. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: API design question for dbf.py
On Fri, Jul 6, 2012 at 6:46 PM, Ethan Furman et...@stoneleaf.us wrote: It's checking for equality, not identity. x = float('nan') x in [x] True It's checking for equality OR identity. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: API design question for dbf.py
Devin Jeanpierre wrote: On Fri, Jul 6, 2012 at 6:46 PM, Ethan Furman et...@stoneleaf.us wrote: It's checking for equality, not identity. x = float('nan') x in [x] True It's checking for equality OR identity. Good point. In my case, checking for equality will cover both cases. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list