.split() Qeustion

Steven D'Aprano steve at pearwood.info
Thu Aug 15 03:17:26 EDT 2013


On Wed, 14 Aug 2013 13:05:50 -0400, random832 wrote:

> On Wed, Aug 14, 2013, at 10:32, wxjmfauth at gmail.com wrote:
>> I'm always and still be suprised by the number of hard coded '\n' one
>> can find in Python code when the portable (here win)
>> 
>> >>> os.linesep
>> '\r\n'
>> 
>> exists.
> 
> Because high-level code isn't supposed to use the os module directly.

Say what? My brain hurts. The os module is full of lots of platform 
independent goodies. It is the right way to split and combine pathnames, 
test environment variables, manipulate file permissions, and other useful 
tasks.


> Text-mode streams automatically convert newlines you write to them.

Maybe they do, maybe they don't. It depends on whether Python is built 
with universal newline support, and what sort of text-mode stream you are 
using, and a bunch of other rules that make it a little more complicated 
than just "automatically convert".


-- 
Steven



More information about the Python-list mailing list