Monmonja Programming Blog

October 30, 2008

CamelCase in Python / Django

Filed under: App Engine,Programming — Tags: , , — admin @ 8:01 am

Here is a small script for making CamelCase string in python

import re
from string import capitalize
def camelcase(value):
return "".join([capitalize(w) for w in re.split(re.compile("[\W_]*"), value)])

in django just add
@register.filter

making it
import re
from string import capitalize
@register.filter
def camelcase(value):
return "".join([capitalize(w) for w in re.split(re.compile("[\W_]*"), value)])

Hope it help.

Share and Enjoy:
  • Digg
  • Reddit
  • Slashdot
  • del.icio.us
  • StumbleUpon
  • TwitThis
  • Fark
  • Facebook
  • Technorati
  • Sphinn
  • Furl
  • Google Bookmarks
  • Mixx

2 Comments »

  1. saved my day, thanks!

    Comment by tutuca — March 21, 2009 @ 7:42 am

  2. Thanks for this post. I am new at development and this was a big help.

    Comment by Jackie Vaught — March 7, 2010 @ 3:36 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Monmonja Programming Blog is Digg proof thanks to caching by WP Super Cache