On 18/07/2012 18:28, Ed Leafe wrote:
On Jul 18, 2012, at 12:16 PM, Ethan Furman wrote:
Your memory is good! I typed it in wrong.
Well, I was an MVP for Visual Foxpro for 10 years, so...
;-)
I see four other options:
0) don't move the pointer (listed for completeness)
1) go to that record anyway
2) go to the next undeleted record
3) go to the seventh undeleted record (possibly the least practical)
4) raise an exception
I still don't like it. Any opinion on the other four choices? I'm leaning
towards 1, possibly with 4 as an option:
#4 is probably the most Pythonic approach. The calling code can then
decide how to react to attempting to access a deleted record. Even if you're
accessing data stored in VFP tables, your module should be as Pythonic as
possible.
I disagree. I think that if you can see it should be able to go to it.
I think that the closest analogue is a list, although maybe you should
be able to hide any records which are marked for deletion.
# Print all of the names.
records.include_deleted = True
print("There are {} names".format(len(records)))
for r in records:
if r.deleted:
print("\t{} (deleted)".format(r["name"]))
else:
print("\t{}".format(r["name"]))
# Print all but the deleted names.
records.include_deleted = False
print("There are {} names".format(len(records)))
for r in records:
print(r["name"])
Part of the reason I feel this is reasonable is that with my dbf module it is
possible to create an index that does /not/ include certain records:
Deleting a record in VFP doesn't remove it from the index; I believe it
marks that index entry as deleted, too. I think that as long as you treat the
deleted status as the same as any other boolean column you'll be good.
--
http://mail.python.org/mailman/listinfo/python-list