Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'root': 0.05; 'context': 0.07; 'string': 0.09; 'alias': 0.09; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; "'''": 0.16; '-tkc': 0.16; "can't.": 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'skip:/ 70': 0.16; 'string:': 0.16; 'subject:format': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'second': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'url:127': 0.31; 'older': 0.33; 'skip:d 20': 0.34; 'but': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'server': 0.38; 'solve': 0.60; 'to:addr:gmail.com': 0.65; 'url:0': 0.67; 'percent': 0.68; '500': 0.70; 'subject:have': 0.80; 'received:50.22': 0.84; 'expires': 0.91 Date: Sun, 20 Apr 2014 18:43:44 -0500 From: Tim Chase To: Mariano DAngelo Subject: Re: how to string format when string have { In-Reply-To: <2075921a-dd3e-4788-86fb-e751ad98ee0e@googlegroups.com> References: <2075921a-dd3e-4788-86fb-e751ad98ee0e@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398037431 news.xs4all.nl 2865 [2001:888:2000:d::a6]:39219 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70440 On 2014-04-20 15:34, Mariano DAngelo wrote: > I have the following string: ... > but since the string have { i can't. > Is there a way to solve this? I second Chris Angelico's suggestion about using the older percent formatting: nginx_conf = ''' server { listen 80; server_name dev.%(project_url)s; location / { proxy_pass http://127.0.0.1:8080; include /etc/nginx/proxy.conf; } location /media { alias /home/mariano/PycharmProjects/%(project_name)s/%(project_name)s/media; expires 30d; } location /static { alias /home/mariano/PycharmProjects/%(project_name)s/%(project_name)s/static; expires 30d; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }''' context = { "project_name":project_name, "project_url":project_url, } print(nginx_conf % context) -tkc