Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7106

Re: new string formatting with local variables

Date 2011-06-06 11:57 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: new string formatting with local variables
References <mailman.2490.1307376958.9059.python-list@python.org> <slrniuq75p.47d.steve@news.mixmin.net>
Newsgroups comp.lang.python
Message-ID <mailman.2502.1307385872.9059.python-list@python.org> (permalink)

Show all headers | View raw


Steve Crook wrote:
> On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
> Message-Id: <mailman.2490.1307376958.9059.python-list@python.org>:
> 
>> solo = 'Han Solo'
>> jabba = 'Jabba the Hutt'
>> print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
>> # Han Solo was captured by Jabba the Hutt
> 
> How about:-
> 
> print "%s was captured by %s" % (solo, jabba)

Or even

print "{} was captured by {}".format(solo, jabba)

or how about

print "{victim} was captured by {captor}".format(
         victim=solo, captor=jabba)

or maybe

print "{hapless_twit} was captured by {mega_bad_dude}".format(
         hapless_twit=solo, mega_bad_dude=jabba)


~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

new string formatting with local variables Jabba Laci <jabba.laci@gmail.com> - 2011-06-06 12:15 -0400
  Re: new string formatting with local variables Steve Crook <steve@mixmin.net> - 2011-06-06 18:30 +0000
    Re: new string formatting with local variables Ethan Furman <ethan@stoneleaf.us> - 2011-06-06 11:57 -0700
    RE: new string formatting with local variables "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-06-06 16:21 -0400
    Re: new string formatting with local variables Ethan Furman <ethan@stoneleaf.us> - 2011-06-06 14:07 -0700

csiph-web