title: chr for non-ASCII characters in Python
body: <p>I'm trying to implement a search through a list of strings, in a context where there's no way to use something like <code>str.startswith</code> (If you're curious about it, I'm querying the app engine datastore.) I'd like to look for every string that has a certain prefix, let's say 'py'.</p>
  
  <p>I have comparison operators at my disposal, so I was thinking I could implement this as follows.</p>
  
  <pre><code>#pseudo code
  search = "py"
  search_strings_where(s &gt; search, s &lt; chr(ord(search[0]) + 1)
  </code></pre>
  
  <p>The <code>chr(ord(search[0]) + 1)</code> is supposed to be the character that's in lexicographical order right after the first character of the search query.</p>
  
  <p>The problem is that this won't work. take for example <code>ord(u"‰")</code>, which returns 8240. But putting that into <code>chr</code>again raises an error.</p>
  
  <pre><code>ValueError: chr() arg not in range(256)
  </code></pre>
  
  <p>How could I solve this?</p>
  
  <p>EDIT
  Just found out about unichr, checking if this works. I will write an answer if it does.</p>