On Wednesday, November 7, 2012 5:16:44 AM UTC+8, Michael Bayer wrote:
> this is not valid Python, so I'm not sure what feature you'd be looking
> for here:
> >>> l = 'hi'
> >>> def foo():
> ... l = l
> ...
> >>> foo()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<stdin>", line 2, in foo
> UnboundLocalError: local variable 'l' referenced before assignment
> On Nov 6, 2012, at 3:12 PM, George Xie wrote:
> hi all
> consider following template
> from mako.template import Template
> t = Template(
> """
> <%
> l = l
> %>
> """.strip(),
> strict_undefined=True,
> )
> print t.render(l=l)
> would raise "NameError: name 'l' is not defined"
> mako thought 'l' is locally_declared, is this a bug or feature?
> I think this is caused by scope rule simulation,
> say that though 'l' actually in function scope of render_body, where 'l'
> could be get from render context,
> but in fact it is in the logical global scope, which is mimicked by mako,
> therefore mako wont try to exact 'l' from context.
> --
> You received this message because you are subscribed to the Google Groups
> "Mako Templates for Python" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mako-discuss/-/CNPrCGaY4coJ.
> To post to this group, send email to mako-d...@googlegroups.com<javascript:>
> .
> To unsubscribe from this group, send email to
> mako-discuss...@googlegroups.com <javascript:>.
> For more options, visit this group at
> http://groups.google.com/group/mako-discuss?hl=en.