title: How can I check if a Python unicode string contains non-Western letters?
body: <p>I have a Python Unicode string. I want to make sure it only contains letters from the Roman alphabet (A through Z), as well as letters commonly found in European alphabets, such as ß, ü, ø, é, à, and î. It should <em>not</em> contain characters from other alphabets (Chinese, Japanese, Korean, Arabic, Cyrillic, Hebrew, etc.). What's the best way to go about doing this?</p>
  
  <p>Currently I am using this bit of code, but I don't know if it's the best way:</p>
  
  <pre><code>def only_roman_chars(s):
      try:
          s.encode("iso-8859-1")
          return True
      except UnicodeDecodeError:
          return False
  </code></pre>
  
  <p>(I am using Python 2.5. I am also doing this in Django, so if the Django framework happens to have a way to handle such strings, I can use that functionality -- I haven't come across anything like that, however.)</p>