string.Template question
Wells Oliver
thewellsoliver at gmail.com
Mon Apr 5 15:22:29 EDT 2010
Can you use dicts with string.Template?
e.g. a structure like:
game = {
'home': {'team': row['home_team_full'], 'score': row['home_score'],
'record': '0-0', 'pitcher': {
'id': home_pitcher.attrib['id'], 'name':
home_pitcher.attrib['last_name'], 'wins': home_pitcher.attrib['wins'],
'losses': home_pitcher.attrib['losses']
}, 'win': home_win}
}
Then, in the template, 'game' is passed, but I want to access like
$home.pitcher.id
This doesn't seem to work, though. Is it possible? Or must everything
in the dict passed to string.Template be one-level deep string
variables?
More information about the Python-list
mailing list