[Biopython-dev] text files and mac

Peter biopython at maubp.freeserve.co.uk
Thu Dec 9 17:07:57 UTC 2010


2010/12/9 Tiago Antão <tiagoantao at gmail.com>:
> Hi,
>
> I am writing this email to ask for some advice (many thanks in advance
> for any suggestion).
> I was contacted regarding a bug on the genepop parser on mac (I have
> no Mac, so I really do not have how to test, neither experience
> developing there).
>
> The parser opens a text file but, on the mac, sometimes the file is CR
> terminated (is this from old Mac versions? I would expect Mac OS X to
> be text a-la unix - ie CR-LF).
> Well, I've found a recommendation to open files with the U modifier (
> http://www.gossamer-threads.com/lists/python/dev/755361 ).
>
> My question is simple (actually two questions):
> 1. What is the best practice to open text files in terms of modifiers
> for open?

For text files, the universal read lines mode is a sensible default.
It is particularly useful for Unix vs Windows.

> 2. How common is this format on Mac? Is it old stuff or still used? I
> have around 20% Mac users and this was never a reported problem.

I've had some line ending problems, usually from copy/paste
between applications. I've not sat down to try and work out if
there is a pattern. However, simple CR newlines shouldn't
really be used with Mac OS X, but it wouldn't surprise me if
there were buggy programs out there. Certainly the norm on
Mac OS X is to use Unix style LF as the new line character
(compared to DOS/Windows which is CR/LF).

Peter




More information about the Biopython-dev mailing list