6

The following throws a syntax error, "unexpected EOF while parsing":

${foo({'bar':'baz'})}

which I guess is from the inner closing curly brace. This works fine:

${foo(dict(bar='baz'))}

but what's the syntax for using a dictionary literal?

Hollister
  • 3,758
  • 2
  • 20
  • 22

1 Answers1

6

From Brian Rue on the Mako Templates Google Group:

This is a long-outstanding bug; just use dict(). If you need a dictionary with keys that aren't strings, convert a list of tuples into a dict. e.g. instead of this:

${foo({1: 'a', 2: 'b'})}

do this:

${foo(dict([(1, 'a'), (2, 'b')]))}

Hollister
  • 3,758
  • 2
  • 20
  • 22