title: Is there a way to change Python's open() default text encoding?
body: <p>Can I change default <a href="https://docs.python.org/3/library/functions.html#open" rel="noreferrer"><code>open()</code></a> <sup>(<a href="https://docs.python.org/2.7/library/io.html#io.open" rel="noreferrer"><code>io.open()</code> in 2.7</a>)</sup> text encoding in a cross-platform way?</p>
  
  <p>So that I didn't need to specify each time <code>open(...,encoding='utf-8')</code>.</p>
  
  <blockquote>
    <p>In text mode, if <em>encoding</em> is not specified the encoding used is platform dependent: <code>locale.getpreferredencoding(False)</code> is called to get the current locale encoding.</p>
  </blockquote>
  
  <p>Though documentation doesn't specify how to <em>set</em> preferred encoding. The function is in <code>locale</code> module, so I need to change locale? Is there any reliable cross-platform way to set UTF-8 locale? Will it affect anything else other than the default text file encoding?</p>
  
  <p>Or locale changes are dangerous (can break something), and I should stick to custom wrapper such as:</p>
  
  <pre><code>def uopen(*args, **kwargs):
      return open(*args, encoding='UTF-8', **kwargs)
  </code></pre>