Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25585
| Date | 2012-07-18 18:57 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Foxpro goto command and deleted records |
| References | <5005EDC0.6050608@stoneleaf.us> <8416AFAF-E201-4F89-B306-D89F920A00FE@leafe.com> <5006F0F7.8030004@stoneleaf.us> <485D3051-777B-49DA-8FD9-383F5807F827@leafe.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2276.1342634273.4697.python-list@python.org> (permalink) |
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.
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Foxpro goto command and deleted records MRAB <python@mrabarnett.plus.com> - 2012-07-18 18:57 +0100
csiph-web