Blog from the Loft

Thoughts without walls

Blog from the Loft header image 4

Django Tip: Outputting list of items separated by commas, but only if it has more than one item

April 24th, 2008 · No Comments · django

How many times do you need to do this? You have a list of things to output. The list can be empty, has one element, or more. You want to separate each items with a separator for readability. What do you do?
1. The simple but not reader friendly way:
toppings = [ 'cheese','tomatos','pineapple' ]
or toppings = [...]

[Read more →]

Tags: