Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2547
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: proposal to allow to set the delimiter in str.format to something other than curly bracket |
| Date | 2011-04-04 01:17 -0400 |
| References | <a227e6f7-45ae-4404-973f-b69adf156440@d19g2000yql.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.180.1301894287.2990.python-list@python.org> (permalink) |
On 4/3/2011 6:07 AM, Alia Khouri wrote:
> Hi folks,
>
> I've been using ironpython2.7 in a project, and I was generating some
> csharp code when i discovered that I couldn't use use str.format
> because the interference with the brackets-aplenty situation in
> csharp.
>
> In [1]: code = "class {0}Model { public bool IsModel(){ return
> true; } }"
>
> In [2]: code.format('My')
Just double the brackets, just as one doubles '\\' to get '\' in a string.
>>> "class {0}Model {{ public bool IsModel(){{ returntrue; }}
}}".format('My')
'class MyModel { public bool IsModel(){ returntrue; } }'
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
proposal to allow to set the delimiter in str.format to something other than curly bracket Alia Khouri <alia_khouri@yahoo.com> - 2011-04-03 03:07 -0700
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Corey Richardson <kb1pkl@aim.com> - 2011-04-03 06:53 -0400
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Alia Khouri <alia_khouri@yahoo.com> - 2011-04-03 05:17 -0700
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Terry Reedy <tjreedy@udel.edu> - 2011-04-04 01:17 -0400
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Alia Khouri <alia_khouri@yahoo.com> - 2011-04-04 08:42 -0700
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Peter Otten <__peter__@web.de> - 2011-04-04 18:18 +0200
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Alia Khouri <alia_khouri@yahoo.com> - 2011-04-04 13:45 -0700
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Neil Cerutti <neilc@norwich.edu> - 2011-04-05 13:45 +0000
Re: proposal to allow to set the delimiter in str.format to something other than curly bracket Alia Khouri <alia_khouri@yahoo.com> - 2011-04-04 14:32 -0700
csiph-web