Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24669
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-06-29 10:19 -0700 |
| References | <7d1714cb-7aea-4048-bdc5-1b65d0f6c109@googlegroups.com> <mailman.1636.1340989364.4697.python-list@python.org> |
| Subject | Re: format() not behaving as expected |
| From | Josh English <Joshua.R.English@gmail.com> |
| Message-ID | <mailman.1637.1340990373.4697.python-list@python.org> (permalink) |
On Friday, June 29, 2012 10:02:45 AM UTC-7, MRAB wrote:
>
> The ".format" method accepts multiple arguments, so the placeholders in
> the format string need to specify which argument to format as well as
> how to format it (the format specification after the ":").
>
> The "format" function, on the other hand, accepts only a single
> argument to format, so it needs only the format specification, and
> therefore can't accept subscripting or attributes.
>
> >>> c = "foo"
> >>> print "{0:s}".format(c)
> foo
> >>> format(c, "s")
> 'foo'
Thank you. That's beginning to make sense to me. If I understand this, everything between the braces is the format specification, and the format specification doesn't include the braces, right?
Josh
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
format() not behaving as expected Josh English <Joshua.R.English@gmail.com> - 2012-06-29 09:31 -0700
Re: format() not behaving as expected MRAB <python@mrabarnett.plus.com> - 2012-06-29 18:02 +0100
Re: format() not behaving as expected Josh English <Joshua.R.English@gmail.com> - 2012-06-29 10:19 -0700
Re: format() not behaving as expected MRAB <python@mrabarnett.plus.com> - 2012-06-29 18:41 +0100
Re: format() not behaving as expected Josh English <Joshua.R.English@gmail.com> - 2012-06-29 10:19 -0700
Re: format() not behaving as expected Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-06-29 17:08 +0000
Re: format() not behaving as expected Josh English <Joshua.R.English@gmail.com> - 2012-06-29 10:24 -0700
csiph-web