νμ¬ μλ³μ μΆμ μ λ§€μ° μ‘°μ‘νλ©° μ λμ¬ λ³μλ₯Ό κΈ°λ°μΌλ‘ ν©λλ€. μμ΄λμ΄λ μΌλΆ κ³ μ λ³μλ₯Ό λλ릴 μ μλ κ³ μ μλ³μλ‘ λ€μ μ°λ κ²μ λλ€.
μ΄λ κ² νλ©΄ μ½λ μ 체μμ locals()λ₯Ό μ¬μ©ν νμκ° μκ³ ν¨μ κ²½κ³λ₯Ό λμ΄ μλ³μμ κ΄λ ¨λ λͺ κ°μ§ λ¬Έμ κ° μμ λ©λλ€.
μ΄ λ¬Έμ μ μν₯μ λ°λμ§ μ΄λ»κ² μ μ μμ΅λκΉ? "Unbound variable l_SOMETHING"μ΄ λ°κ²¬λμμ΅λλ€.
λ°©κΈ #pocooμμ:
magicbronson: hey mitsuhiko et al., trying to render a Jinja template in a Flask app and getting a very mysterious message: "global name 'l_config' is not defined"
magicbronson: l_config appears nowhere in my code or libraries'
mitsuhiko: magicbronson: that's the scoping bug that i will fix over this summer
mitsuhiko: {% macro foo() %}{{ config }}{% for config in something_else %}{{config}}{% endfor %}{% endmacro %}
mitsuhiko: something like this triggers the bug currently
mitsuhiko: magicbronson: rename the variable inside of the macro to something else
mitsuhiko: {% set cfg = config %}
mitsuhiko: outside the macro
mitsuhiko: or something
Arminμ μ μμ λ¬Έμ λ₯Ό ν΄κ²°νμ΅λλ€.
λλμ΄ μλ£λμμ΅λλ€.
κ°μ₯ μ μ©ν λκΈ
λλμ΄ μλ£λμμ΅λλ€.