Skip to content

Instantly share code, notes, and snippets.

@yumike
Created April 18, 2012 06:03
Show Gist options
  • Save yumike/2411389 to your computer and use it in GitHub Desktop.
Save yumike/2411389 to your computer and use it in GitHub Desktop.
parts = request.path.split('/')
try:
active_menu = parts[1]
except IndexError:
active_menu = ''
try:
active_section = parts[2]
except IndexError:
active_section = ''
# or
parts = request.path.split('/')
parts.extend(('', ''))
active_menu, active_section = parts[1:3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment