String handling bug in Python

Tim Peters tim.one at comcast.net
Sat Apr 27 01:18:06 EDT 2002


[Tim]
>> r-strings were primarily intended to ease writing regular
>> expressions (which can never end with an odd number of
>> backslashes), and people using \ in Windows pathnames are
>> usually missing an obvious alternative (like the forward
>> slash -- Windows API functions couldn't care less which kind
>> of slash you use; and portable code should avoid any literal
>> slashes via os.path.join()).

[Bjorn Pettersen]
> It seems a shame to limit such a potentially useful feature to only one
> domain.

It isn't.  Ask, and people will tell you it's useful in several other
domains too.  The only people who ever whine about this are Windows
programmers who should know better.

> Believe me, I get your windows comment, but when you work in a purely
> windows shop what "should" be done to make code portable doesn't fly
> unless it's also shorter, easier, and makes the code faster <wink>.

Forward slashes are easier for almost everyone to type than backward
slashes, and work fine on Windows.  Paths using forward slashes also run
13-17 times faster in Python code, due to Python's Unix heritage <wink>.

> At-least-they-provide-us-with-free-beer'ly y'rs

while-i-provide-self-serving-lies-that's-windows-for-you-ly y'rs  - tim






More information about the Python-list mailing list