title: How do I find all available locales in Python
body: <p>How can I (on a GNU/Linux system) find all available <em>locales</em> to use with the module <code>locale</code>?</p>
  
  <p>The only thing I find that is close in the the module is the dictionary <code>locale_alias</code> with aliases for locales.
  That is sometimes mentioned as where to look what locales you have, but it doesn't contain all aliases. On my system this program</p>
  
  <pre><code>#! /usr/bin/python3
  import locale
  for k, v in sorted(locale.locale_alias.items()):
      if k.startswith('fr_') or v.startswith('fr_'):
          print('{:20}{}'.format(k, v))
  </code></pre>
  
  <p>prints</p>
  
  <pre><code>c-french            fr_CA.ISO8859-1
  fr                  fr_FR.ISO8859-1
  fr_be               fr_BE.ISO8859-1
  fr_ca               fr_CA.ISO8859-1
  fr_ch               fr_CH.ISO8859-1
  fr_fr               fr_FR.ISO8859-1
  fr_lu               fr_LU.ISO8859-1
  français            fr_FR.ISO8859-1
  fre_fr              fr_FR.ISO8859-1
  french              fr_FR.ISO8859-1
  french.iso88591     fr_CH.ISO8859-1
  french_france       fr_FR.ISO8859-1
  </code></pre>
  
  <p>ignoring all utf-8 locales, like <code>'fr_FR.utf8'</code>, which can indeed be used as argument for <code>locale.setlocale</code>. From the shell, <code>locale -a | grep "^fr_.*utf8"</code> gives</p>
  
  <pre><code>fr_BE.utf8
  fr_CA.utf8
  fr_CH.utf8
  fr_FR.utf8
  fr_LU.utf8
  </code></pre>
  
  <p>showing lots of options. (One way is of course to run this shell command from Python, but I would have thought there is a way to do this directly from Python.)</p>