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


Groups > comp.lang.python > #75291

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!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
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; 'python,': 0.02; 'immutable': 0.09; 'key.': 0.09; 'api': 0.11; 'cc:addr:python- list': 0.11; '"hello': 0.16; 'cc:name:python list': 0.16; 'choice,': 0.16; 'mutable': 0.16; 'tuple': 0.16; 'tuple.': 0.16; 'types,': 0.16; 'wrote:': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'gets': 0.27; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'lists': 0.32; 'could': 0.34; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'list': 0.37; 'sometimes': 0.38; 'subject:"': 0.60; 'choose': 0.64; 'to:addr:gmail.com': 0.65; 'jul': 0.74; 'subject:hello': 0.83; 'subject:this': 0.83; 'subject:you': 0.87
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TN7chF5c4o6TYKYlcotzD42qGjZ83s8yOn8hN/yzAiQ=; b=Vb99DTeXiu/bbiI1EIe+lzNoM9EKtXEdiBVGYAD93fdxKesiGUkonjS6V2OEWQ+o8G FmEaeVPja/rpZ5He2suC2AX5pJzg2jHL77urED2QLMXI3z1l+iAmAzjh0I8FhxSfq5j6 50EMU/uAn0wUPUIwLVV9gplsNcRwLDaE9h1BHHF7Fx8eAnAv0H+BDH/Dl+ZcjeoqXEyM o4sByioQZxjHsZ1lNfgHNVx0U1qEbVpG36wJI+0t4sNaJfVzzDYYnBeUEySo8dbWmkFy nUoLF4PPepaHSB4XwVfya/qNp3jUhpcNwxjwUK6B0ZdwVVNqspNwNbqss91n1sf1BSGL Bxew==
MIME-Version 1.0
X-Received by 10.236.47.201 with SMTP id t49mr6126105yhb.123.1406497039667; Sun, 27 Jul 2014 14:37:19 -0700 (PDT)
In-Reply-To <cefbd1ff-b65f-43ec-947e-2324085a6486@googlegroups.com>
References <cefbd1ff-b65f-43ec-947e-2324085a6486@googlegroups.com>
Date Sun, 27 Jul 2014 14:37:19 -0700
Subject Re: What meaning of this ""hello %s you are %s years old" % x"
From Dan Stromberg <drsalists@gmail.com>
To fl <rxjwg98@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc Python List <python-list@python.org>
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.12372.1406497047.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406497047 news.xs4all.nl 2846 [2001:888:2000:d::a6]:45006
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75291

Show key headers only | View raw


On Sun, Jul 27, 2014 at 11:49 AM, fl <rxjwg98@gmail.com> wrote:
> 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?

You should use a tuple when you need something immutable (readonly),
like a dictionary key.  Immutable objects are good for hashing.

You should use a list when you need something mutable (read/write),
like appending over and over.  Mutable objects are not good for
hashing, because their hash value could change.

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