[Distutils] Reading in Universal Newline mode with pkg_resources
cool-rr at cool-rr.com
Wed Feb 9 21:08:06 CET 2011
On Wed, Feb 9, 2011 at 7:52 PM, P.J. Eby <pje at telecommunity.com> wrote:
> At 08:37 PM 2/8/2011 +0200, cool-RR wrote:
>> I'm accessing a text file using `pkg_resources`. I want to read it in
>> universal newline mode, i.e. to read newlines as '\n' regardless whether
>> they're actually '\r\n'. How do I do this?
> Or, this might be better, since I believe splitlines uses a true Universal
> Newline approach:
Do you think that source_string.replace('\r', '') would work?
> The pkg_resources APIs are binary, rather than text, so you have to do the
> necessary munging yourself, unless you use resource_filename() and open the
> file directly (which has its own issues).
Maybe an option for text-mode reading should be added?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Distutils-SIG