Quantcast
Channel: Mako: Ticket Query
Viewing all articles
Browse latest Browse all 38

#190: Using lambda as default argument breaks

$
0
0

Running this code:

from mako.template import Template
TEXT = """\
<%def name="foo(bar=lambda x, y: x + y)">
    bar(4700, 11)
</%def>
${foo()}
"""
print(Template(TEXT).render())

...results in:

Traceback (most recent call last):
  File "tmp/mako-test/test.py", line 11, in <module>
    print(Template(TEXT).render())
  File "/usr/lib64/python3.2/site-packages/mako/template.py", line 258, in __init__
    (code, module) = _compile_text(self, text, filename)
  File "/usr/lib64/python3.2/site-packages/mako/template.py", line 606, in _compile_text
    code = compile(source, cid, 'exec')
  File "memory:0x7f5927b35ed0", line 18
    def foo(bar=lambda , : (x + y)):
                       ^
SyntaxError: invalid syntax

Expected output:

4711

Tested on version 0.7.0.


Viewing all articles
Browse latest Browse all 38

Trending Articles