title: Python - Compress Ascii String
body: <p>I'm looking for a way to compress an ascii-based string, any help?</p>
  
  <p>I also need to decompress it. I tried zlib but with no help.</p>
  
  <p>What can I do to compress the string into lesser length?</p>
  
  <p>code:</p>
  
  <pre><code>def compress(request):
      if request.POST:
          data = request.POST.get('input')
          if is_ascii(data):
              result = zlib.compress(data)
              return render_to_response('index.html', {'result': result, 'input':data}, context_instance = RequestContext(request))
          else:
              result = "Error, the string is not ascii-based"
              return render_to_response('index.html', {'result':result}, context_instance = RequestContext(request))
      else:
          return render_to_response('index.html', {}, context_instance = RequestContext(request))
  </code></pre>