# How should brackets around braces be escaped?

**URL:** <https://forum.ansible.com/t/how-should-brackets-around-braces-be-escaped/22294>\
**Category:** Ansible Project\
**Created:** [August 15, 2016, 5:38pm UTC](https://forum.ansible.com/t/how-should-brackets-around-braces-be-escaped/22294 "2016-08-15T17:38:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stig\_Dossing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Stig\_Dossing](https://forum.ansible.com/u/Stig_Dossing)\
**Post date:** [August 15, 2016, 5:38pm UTC](https://forum.ansible.com/t/how-should-brackets-around-braces-be-escaped/22294/1 "2016-08-15T17:38:55Z")

</div>

Hi.

I’m having some trouble getting a fragment of a group\_vars/all file to pass syntax checking. I’m on the latest github code at the time of writing (daf6eb97d3b0d059e0856015b2eb62d32281b9ad).

Here’s a minimal example similar to what I need in the group\_vars file:

`  
my\_env: dev  
env\_upper\_bracketed: “[{{ my\_env | upper }}]”  
username: “{{ env\_upper\_bracketed }} user”

`

This throws the warnings

`  
[WARNING]: Exception in safe\_eval() on expr: [DEV] (name ‘DEV’ is not defined)

` `  
[WARNING]: SyntaxError in safe\_eval() on expr: [DEV] user (unexpected EOF while parsing  
(, line 1))  
`

I would expect the string “[DEV]” to be the value of env\_upper\_bracketed, and for username to be set to “[DEV] user”, but it seems like the parser disagrees. Single quoting the brackets isn’t really a workaround, since the single quotes then become part of the value of env\_upper\_bracketed. Backslash escaping is only allowed for non-printable characters so that’s not an option either.

Any suggestions for what I’m doing wrong, or did I hit an edge case bug in the parser?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 18, 2016, 6:35pm UTC](https://forum.ansible.com/t/how-should-brackets-around-braces-be-escaped/22294/2 "2016-08-18T18:35:32Z")

</div>

Just tried it with 2.1.1, no error and debug give me this  
TASK [debug]
