Python dos2unix one liner

Martin P. Hellwig martin.hellwig at dcuktec.org
Sat Feb 27 05:14:02 EST 2010


On 02/27/10 09:36, @ Rocteur CC wrote:
<cut dos2unix oneliners;python vs perl/sed/awk>
Hi a couple of fragmented things popped in my head reading your 
question, non of them is very constructive though in what you actually 
want, but here it goes anyway.

- Oneline through away script with re as a built in syntax, yup that 
sounds like perl to me.

- What is wrong with making an executable script (not being one line) 
and call that, this is even shorter.

- ... wait a minute, you are building something in python (problem with 
string.strip - why don't you use the built-in string strip method 
instead?) which barfs on the input (win/unix line ending), should the 
actual solution not be in there, i.e. parsing the line first to check 
for line-endings? .. But wait another minute, why are you getting \r\n 
in the first place, python by default uses universal new lines?

Hope that helps a bit, maybe you could post the part of the code what 
you are doing for some better suggestions.

-- 
mph



More information about the Python-list mailing list