Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66147

Re: Wait... WHAT?

References (3 earlier) <20140212161427.0a9843d5@bigbox.christie.dr> <ldh0hj$nlj$1@ger.gmane.org> <20140212184432.1df9b491@bigbox.christie.dr> <ldh5cr$bdk$1@ger.gmane.org> <20140212212953.458b810a@bigbox.christie.dr>
Date 2014-02-13 14:47 +1100
Subject Re: Wait... WHAT?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6821.1392263231.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Feb 13, 2014 at 2:29 PM, Tim Chase
<python.list@tim.thechases.com> wrote:
> My original point (though
> perhaps not conveyed as well as I'd intended) was that only bytes get
> written to the disk, and that some encoding must take place.  It can
> be done implicitly using some defaults which may break (as demoed),
> whereas one would be better off doing it explicitly such as Chris
> shows

And since the default encoding varies based on matters outside your
script (most notably platform - I tried this on Windows and Linux, and
got a default of UTF-8 on Linux and CP-1252 on Windows; but
environment variables and such can interfere too), I would say that
omitting the encoding= parameter should be done ONLY when you actually
have no idea what the encoding is, only that it's "probably something
from the rest of the system". And, well, if that's what you're looking
at, you definitely can't trust to reading or writing non-ASCII (you
can probably trust ASCII). When you create a file that you'll read
back yourself, specify an encoding.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Wait... WHAT? eneskristo@gmail.com - 2014-02-12 11:43 -0800
  Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 13:13 -0700
  Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:21 -0800
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 20:38 +0000
    Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 14:35 -0700
    Re: Wait... WHAT? Michael Torrie <torriem@gmail.com> - 2014-02-12 14:39 -0700
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 16:14 -0600
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 23:36 +0000
    Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 17:01 -0700
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 18:44 -0600
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-13 00:59 +0000
    Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 12:10 +1100
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 21:29 -0600
    Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 14:47 +1100
      Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-13 09:46 -0800
        Re: Wait... WHAT? MRAB <python@mrabarnett.plus.com> - 2014-02-13 18:25 +0000
        Re: Wait... WHAT? Michael Torrie <torriem@gmail.com> - 2014-02-13 15:22 -0700
  Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:43 -0800
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 20:56 +0000
      Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:59 -0800
        Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 08:17 +1100
        Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 21:23 +0000
    Re: Wait... WHAT? Grant Edwards <invalid@invalid.invalid> - 2014-02-12 23:09 +0000

csiph-web