[DB-SIG] dBase III and VFP tables
Carl Karsten
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
>>> whitespace?
>>
>>
>> Oh yeah, that.
>>
>> --> "abc ".strip()
>> 'abc'
>>
>> 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
> well:
>
> 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'
True
But this works:
>>> '' in ['a','b','c']
False
>>> 'b' in ['a','b','c']
True
>
> 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.
My advice:
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.
>
> ~Ethan~
> _______________________________________________
> DB-SIG maillist - DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
--
Carl K
More information about the DB-SIG
mailing list