[Python] How to omit curly braces when using cookiecutter?

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    I'm building a cookiecutter template in Python, something fairly simple for now, that looks like this:

    ├── {{ cookiecutter.project_name }}
    │ └── test.py
    │
    └── cookiecutter.json


    When I run the cookiecutter command on the command line and point it to this template, it correctly asks me for the project_name input. However, the problem is that in my test.py script, there is a print statement with double curly braces as well, so in the end, the cookiecutter command fails, with the following error:

    File "./test.py", line 73, in template
    jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got ':'
    File "./test.py", line 73
    print(('{{"RequestId":"{0}", '


    Is there a way to tell cookiecutter to omit certain curly braces?

    Continue reading...

Compartilhe esta Página