[DB-SIG] dBase III and VFP tables
carl at personnelware.com
Wed Jul 20 20:47:07 CEST 2011
On Wed, Jul 20, 2011 at 1:46 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Carl Karsten wrote:
>>> Given this little example, would you still not worry about trailing
>> Oh yeah, that.
>> --> "abc ".strip()
>> if rec.full_name.strip() == 'John Doe'
>> Personally, I would leave it at that.
>> half baked idea: If you want to add some code to hide that, add some
>> sort of auto-strip to the driver so it drops the extra spaces.
> Heh, that's what I've been doing. It did two things for me: 1) made
> equality checking easier; and 2) made boolean checks make sense. It has its
> own problems though -- mainly that single character empty fields don't work
> if rtyp in 'FMU': # is this Forwardable, Moved, or Undeliverable?
> ' ' gets stripped down to '', and '' is in every string, this doesn't work.
huh. yeah, its true. i'm kinda surprised.
>>> '' in 'abc'
But this works:
>>> '' in ['a','b','c']
>>> 'b' in ['a','b','c']
> And yes, I could use a .strip() every time I have a field comparison, but I
> have *lots* of them in my code, and it feels an awful lot like unnecessary
> boiler plate.
I know what you mean.
2 wads of code: the dbapi module and some wrapper to make it nicer to work with.
> Okay, I'll leave the default at str, and make Char, like Date, DateTime, and
> Logical, be available options.
> DB-SIG maillist - DB-SIG at python.org
More information about the DB-SIG