Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111263
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ben Finney <ben+python@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Subject | Re: one command on backslash and space for review |
| Date | Mon, 11 Jul 2016 15:09:14 +1000 |
| Lines | 31 |
| Message-ID | <mailman.178.1468213766.2295.python-list@python.org> (permalink) |
| References | <CACT3xuWi-BTNM2QRe3Gdk4ZyqyFn-m0U-RNPxJXS2sgMd55ciA@mail.gmail.com> <CALwzidk1Z30Q9RiLQgcM50+o_jDx-yVYcB7mnEH2KNfbaCg8zw@mail.gmail.com> <CACT3xuW2xjbApThg59vwSTeiC6fQmF0YjhNteaxWNNBkqoxaeg@mail.gmail.com> <85r3b0vk05.fsf@benfinney.id.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de GvAEiiN+CdJZnGr6SCqX7wHC6Ry8hHMPCl4LUBoKGelg== |
| Cancel-Lock | sha1:tiuPI17hNfTBY5iGrdYaQ/dcXwY= |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'defaults': 0.05; 'cmd': 0.09; 'parameter.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:command': 0.09; 'syntax': 0.13; 'appropriate': 0.14; 'opposite': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'string': 0.17; 'integer': 0.18; '(in': 0.18; 'creates': 0.18; '>>>': 0.20; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'format,': 0.27; 'object,': 0.27; 'sleep': 0.29; 'strings,': 0.29; 'wright': 0.29; "i'm": 0.30; 'e.g.': 0.30; 'url:python': 0.33; 'case,': 0.34; 'gives': 0.35; 'asking': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'format': 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'choose': 0.68; 'skip:\xe2 10': 0.70; '_o__)': 0.84; 'received:125': 0.84; 'subject:review': 0.84; 'subject:space': 0.84; 'url:string': 0.84; 'expiration': 0.91; 'thoroughly': 0.91; 'birth': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <85r3b0vk05.fsf@benfinney.id.au> |
| X-Mailman-Original-References | <CACT3xuWi-BTNM2QRe3Gdk4ZyqyFn-m0U-RNPxJXS2sgMd55ciA@mail.gmail.com> <CALwzidk1Z30Q9RiLQgcM50+o_jDx-yVYcB7mnEH2KNfbaCg8zw@mail.gmail.com> <CACT3xuW2xjbApThg59vwSTeiC6fQmF0YjhNteaxWNNBkqoxaeg@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:111263 |
Show key headers only | View raw
Ganesh Pal <ganesh1pal@gmail.com> writes:
> How will I format number to strings using .format ??
To make best use of ‘str.format’, read its documentation thoroughly
<URL:https://docs.python.org/3/library/string.html#formatstrings>.
To format numbers to strings, you choose which representation you want;
e.g. “decimal integer”. Then, use the appropriate format syntax for that
representation (in that case, the ‘d’ type specifier).
> Example
>
> >>> str(num)
That creates a new string object, by asking the integer object to return
its string representation. That gives you no choice in the
representation, which is the opposite of what you are asking for.
> >>> cmd = "run_parallel -za{} -s 'daemon -cf xyz; sleep 1'".format(str(num))
The ‘{}‘ format string takes all the defaults for that parameter. If you
want to customise the format, choose the specification and put it inside
the ‘{’ and ‘}’ characters.
--
\ “I know when I'm going to die, because my birth certificate has |
`\ an expiration date.” —Steven Wright |
_o__) |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: one command on backslash and space for review Ben Finney <ben+python@benfinney.id.au> - 2016-07-11 15:09 +1000
csiph-web