On Tue, 2011-01-11 at 05:27 -0800, andrei wrote:
> Or  $:errors.get("player%d" % loop.index, "") to make it return empty
> string if specific key doesn't exist.

I declared 'errors' dict using collections.defaultdict(str). If key is
missing then '' (empty string) is returned. This reduces typing a bit :)

>>> import collections
>>> errors = collections.defaultdict(str)
>>> errors['player1'] = 'Required'
>>> errors['player20']
''
>>> errors['player1']
'Required'
>>> 


-- 
Sergei Sadovski <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to