Viewing posts for the category Python

Python/Django Tips n' Tricks Cheatsheet

Posted by: scoopseven in Django Python 12 years, 2 months ago

Converting a unicode string to a list of strings
http://stackoverflow.com/questions/5001385/unicode-to-python-object-conversion
n = [e.encode('utf-8') for e in s.strip('[]').split(',')]

read more / 0 comments

The _imaging C module is not installed

Posted by: scoopseven in Linux Python 12 years, 9 months ago

While trying to use PIL on a Arch linux box (python 2.6.7) I kept getting the dreaded "The _imaging C module is not installed" error message.  I tried installing libjpeg using pacman and from source. I tried installing freetype2 using pacman and from source. After each of these attempts, I reinstalled PIL with the --update option and went through the...

read more / 0 comments

Finding First or Last Item in a Python List

Posted by: scoopseven in Django Python Sphinx 12 years, 11 months ago

I had a small piece of code I was using to parse a search string in Python for Sphinx.  When you pass "verizon | mobile | at&t" to Sphinx (in boolean mode) it happily returns results.  However, if you pass "verizon | mobile | at&t | " it throws an "unexpected $end near ''" error.  So I needed to not add the extra pipe/or for the last element in my search string.  Using split() to turn the string into a list and then using the [-1] index, you're able to determine if you're on the last element and not add the extraneous "or."

read more / 0 comments

Sphinx Mode in Python / SphinxSearch Class

Posted by: scoopseven in Django Python Sphinx 12 years, 11 months ago

In order to get Sphinx to work in boolean mode in Python/Django, you need to pass the "mode" argument as it's plain text value to the SphinxSearch class.

read more / 0 comments

Zinnia, My Django Blog

Posted by: scoopseven in Apple Django Linux Python WordPress 13 years ago

UPDATE: 4/7/11 !!! IMPORTANT !!! Read the comments between Julien and I below before installing or deciding to install Zinnia.  It's far easier than I lay out in this post.  I'm leaving here for reference of what not to do :) --Mark

read more / 0 comments

Recent Tweets

Recent Posts

Archive

2013
2012
2011
2010
2009
2008
2007
2006

Categories

Authors

Feeds

RSS / Atom