[DB-SIG] dBase III and VFP tables

Carl Karsten carl at personnelware.com
Wed Jul 20 19:46:00 CEST 2011


On Wed, Jul 20, 2011 at 12:36 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Carl Karsten wrote:
>>
>> On Wed, Jul 20, 2011 at 11:33 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>>
>>> as well as ignoring trailing white space for comparisons)
>>
>> _backwards computability_ is the only reason to implement this in the
>> driver, and given there is currenly no code relying on it, nothing
>> will break if you don't.  So don't :)
>
> Okay, have you written a book?  'Cause I'm ready to buy it.  ;)
>
> The reason I have that (and I can make it be the option, not the default),
> is that without it I have to write.... oh -- I could use .startswith(),
> couldn't I?  Well, I was going to say that code such as:
>
> # look for so-and-so...
> for rec in table:
>    if rec.full_name == 'John Doe':
>        do_something_with(rec)
>
> and of course this will fail because FULL_NAME is a 40 character field, and
> I should have said
>
>    if rec.full_name == 'John Doe                                '
>
> and I really don't want to do that!  Also, .startswith() is not the same as
> ignoring trailing whitespace.
>
> 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.


-- 
Carl K


More information about the DB-SIG mailing list