Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:
On Tue, 07 Jun 2011 10:11:01 +1000, Ben Finney wrote:
I tend to use ‘ufoo {bar} baz.format(**vars())’, since ‘vars’ can
also take the namespace of an object. I only need to remember one
“give me the namespace” function for
On Mon, Jun 6, 2011 at 9:15 AM, Jabba Laci jabba.l...@gmail.com wrote:
Hi,
I'd like to simplify the following string formatting:
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
What I
On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
Message-Id: mailman.2490.1307376958.9059.python-l...@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
Steve Crook wrote:
On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
Message-Id: mailman.2490.1307376958.9059.python-l...@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
On Mon, Jun 6, 2011 at 10:15 AM, Jabba Laci jabba.l...@gmail.com wrote:
Hi,
I'd like to simplify the following string formatting:
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
What
print {} was captured by {}.format(solo, jabba)
Is this Python2.7 specific?
Python 2.6.x :
print {} was captured by {}.format('t1', 't2')
ValueError: zero length field name in format
Ramit
This communication is for informational purposes only. It is not
intended as an offer or
Prasad, Ramit wrote:
print {} was captured by {}.format(solo, jabba)
Is this Python2.7 specific?
Python 2.6.x :
print {} was captured by {}.format('t1', 't2')
ValueError: zero length field name in format
Apparently it is 2.7 and greater -- my apologies for not specifying that.
~Ethan~
--
Chris Rebert c...@rebertia.com writes:
print {solo} was captured by {jabba}.format(**locals()) # RIGHT
I tend to use ‘ufoo {bar} baz.format(**vars())’, since ‘vars’ can also
take the namespace of an object. I only need to remember one “give me
the namespace” function for formatting.
You must
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
You must use prefix-** in the call to unpack the mapping as keyword
arguments. Note that using locals() like this isn't best-practice.
Who says so, and do you find their argument convincing? Do you have a
reference
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
Chris Rebert c...@rebertia.com writes:
print {solo} was captured by {jabba}.format(**locals()) # RIGHT
I tend to use ‘ufoo {bar} baz.format(**vars())’, since ‘vars’ can also
take the namespace of an object. I only
On Tue, 07 Jun 2011 10:11:01 +1000, Ben Finney wrote:
Chris Rebert c...@rebertia.com writes:
print {solo} was captured by {jabba}.format(**locals()) # RIGHT
I tend to use ‘ufoo {bar} baz.format(**vars())’, since ‘vars’ can also
take the namespace of an object. I only need to remember one
11 matches
Mail list logo