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


Groups > comp.lang.python > #75289

Re: What meaning of this ""hello %s you are %s years old" % x"

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gary.herron@islandtraining.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'output': 0.05; 'string': 0.09; 'formatting': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'api': 0.11; 'template': 0.14; '"hello': 0.16; 'choice,': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'tuple.': 0.16; 'types,': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'seems': 0.21; 'example': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'received:(smtp server)': 0.26; 'post': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'that.': 0.31; 'gary': 0.31; 'operations.': 0.31; 'values.': 0.31; 'lists': 0.32; 'probably': 0.32; 'another': 0.32; 'url:python': 0.33; 'older': 0.33; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'method': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'sometimes': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'subject:"': 0.60; 'url:3': 0.61; 'details.': 0.61; 'choose': 0.64; 'details': 0.65; 'subject:hello': 0.83; 'subject:this': 0.83; 'missing.': 0.84; 'subject:you': 0.87
X-Virus-Scanned OK
X-Sender-Id gary.herron@islandtraining.com
Date Sun, 27 Jul 2014 13:02:18 -0700
From Gary Herron <gary.herron@islandtraining.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version 1.0
To python-list@python.org
Subject Re: What meaning of this ""hello %s you are %s years old" % x"
References <cefbd1ff-b65f-43ec-947e-2324085a6486@googlegroups.com>
In-Reply-To <cefbd1ff-b65f-43ec-947e-2324085a6486@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.12371.1406491903.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406491903 news.xs4all.nl 2907 [2001:888:2000:d::a6]:39557
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75289

Show key headers only | View raw


On 07/27/2014 11:49 AM, fl wrote:
> Hi,
>
> I get a post on tuple, see below please, on line. It seems that something is
> missing. I want to learn tuple from this example as well.
>
> Could you explain it to me (a tuple % another tuple)?
>
>
> Thanks,
>
>
>
>
>
>
> http://stackoverflow.com/questions/1708510/python-list-vs-tuple-when-to-use-each
>
> In Python, when should you use lists and when tuples?
>
> Sometimes you don't have a choice, for example if you have
>
> "hello %s you are %s years old" % x
> then x must be a tuple.
>
> But if I am the one who designs the API and gets to choose the data types, then
> what are the guidelines?

That's not tuple%tuple, but rather string%tuple.  And string%tuple is 
the older method of formatting an output string from a template and a 
tuple of values.  See 
https://docs.python.org/2/library/stdtypes.html#string-formatting for 
details.

However, if you are just learning Python, you should probably use the 
*newer* formatting operations.  See 
https://docs.python.org/3.3/library/string.html#formatspec for details 
of that.

Gary Herron

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


Thread

What meaning of this ""hello %s you are %s years old" % x" fl <rxjwg98@gmail.com> - 2014-07-27 11:49 -0700
  Re: What meaning of this ""hello %s you are %s years old" % x" Gary Herron <gary.herron@islandtraining.com> - 2014-07-27 13:02 -0700
  Re: What meaning of this ""hello %s you are %s years old" % x" Dan Stromberg <drsalists@gmail.com> - 2014-07-27 14:37 -0700
  Re: What meaning of this ""hello %s you are %s years old" % x" Albert-Jan Roskam <fomcl@yahoo.com> - 2014-07-28 00:41 -0700
  Re: What meaning of this ""hello %s you are %s years old" % x" Chris Angelico <rosuav@gmail.com> - 2014-07-28 17:58 +1000

csiph-web