Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: using binary in python Date: Mon, 09 Nov 2015 12:56:08 +0200 Organization: A noiseless patient Spider Lines: 19 Message-ID: <87d1vjigqf.fsf@elektro.pacujo.net> References: <20151108212706.GA29701@z-sverige.nu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="6909"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kVL6AM/vbdx94G+mCgSW8" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:oRsDGQYms+OgoTedZfArVkIRTZQ= sha1:NYlVkFsy7k+a9nagfVdP4pQU3Qs= Xref: csiph.com comp.lang.python:98510 Michiel Overtoom : > If you're on Windows, don't forget to include a 'b' in the mode string > of the open() call, otherwise Python will assume that you're opening a > text file. Python has brought that blessing to other operating systems, as well. One of the principal UNIX innovations was to see files as simple byte sequences. The operating system would place no semantics on the meaning or structure of the bytes. Python presents a different concept of a file; Python files are either text files or binary files. The dichotomy is built on top of the UNIX file system. However, the Python model "leaks" in that nothing prevents you from opening a binary file as a text file or vice versa. Marko