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


Groups > comp.lang.python > #14990

Re: How to isolate a constant?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'oct': 0.02; 'unexpected': 0.07; '>>>>': 0.09; 'exception.': 0.09; '25,': 0.12; 'operations,': 0.15; '[:]': 0.16; 'bieber': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.20; "doesn't": 0.22; 'cc:2**0': 0.22; 'header :In-Reply-To:1': 0.22; 'tue,': 0.23; 'modification': 0.23; 'pm,': 0.24; 'string': 0.26; 'lee': 0.28; 'modify': 0.28; 'pass': 0.29; 'message-id:@mail.gmail.com': 0.29; 'second': 0.29; 'cc:addr:python.org': 0.30; "who'd": 0.30; 'subject:?': 0.31; "didn't": 0.31; 'received:209.85.161.46': 0.31; 'received:mail- fx0-f46.google.com': 0.31; 'usually': 0.32; 'probably': 0.33; 'list.': 0.35; 'received:209.85.161': 0.35; 'subject:How': 0.35; 'assuming': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'either': 0.39; 'needing': 0.64; '"what': 0.67; 'yourself': 0.67; 'dennis': 0.77
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=WWUIFm5D6HhnlrrakNOiNErNoXOkGU8v28R3MBbTZzg=; b=A1xLBWAL/MKba4G093Phl1k0ULB0muv1NuInpsjTYmmhy+jdg8SmtbcLQGZlu2w2rz 0ubp735Cc1auqhjpoupix6kDG0faoNNK/Zu/wh41EGegVH+sF1LlVLs+n2L2Iqgq7/CG SPywGT9VffR9U0YEVxjnUEnQHYTaTRmuq2FcI=
MIME-Version 1.0
In-Reply-To <j87j1j$hkc$1@dough.gmane.org>
References <f5539538-d079-4be1-b2c0-d98d3fc6a33f@h39g2000prh.googlegroups.com> <mailman.2138.1319330815.27778.python-list@python.org> <4EA71323.2030500@yahoo.com> <CALwzid=aWPuBGXw6g+10Z6FWRKXPm6f4syt7Q9UJCmisFCSk1g@mail.gmail.com> <j87j1j$hkc$1@dough.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 25 Oct 2011 18:30:32 -0600
Subject Re: How to isolate a constant?
To Dennis Lee Bieber <wlfraed@ix.netcom.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2221.1319589064.27778.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1319589064 news.xs4all.nl 6916 [2001:888:2000:d::a6]:35187
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:14990

Show key headers only | View raw


On Tue, Oct 25, 2011 at 6:08 PM, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
> Where's the line form to split those who'd prefer the first vs the
> second result in this sample <G>:
>
>>>> unExpected = "What about a string"
>>>> firstToLast = unExpected[:]

Strings are immutable.  That doesn't suffice to copy them, even
assuming you would want to do so in the first place.

>>> unExpected is firstToLast
True

If you find yourself needing to make a copy, that usually means that
you plan on modifying either the original or the copy, which in turn
means that you need a type that supports modification operations,
which usually means a list.  If you pass in a string and then copy it
with [:] and then try to modify it, you'll get an exception.  If you
don't try to modify it, then you probably didn't need to copy it in
the first place.

Cheers,
Ian

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


Thread

How to isolate a constant? Gnarlodious <gnarlodious@gmail.com> - 2011-10-22 17:26 -0700
  Re: How to isolate a constant? Chris Rebert <clp2@rebertia.com> - 2011-10-22 17:41 -0700
    Re: How to isolate a constant? Gnarlodious <gnarlodious@gmail.com> - 2011-10-22 18:01 -0700
      Re: How to isolate a constant? 88888 Dihedral <dihedral88888@googlemail.com> - 2011-10-22 22:12 -0700
      Re: How to isolate a constant? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-23 05:32 +0000
      Re: How to isolate a constant? Paul Rudin <paul.nospam@rudin.co.uk> - 2011-10-23 11:23 +0100
  Re: How to isolate a constant? MRAB <python@mrabarnett.plus.com> - 2011-10-23 01:46 +0100
    Re: How to isolate a constant? Alan Meyer <ameyer2@yahoo.com> - 2011-10-25 15:50 -0400
      Re: How to isolate a constant? Ian Kelly <ian.g.kelly@gmail.com> - 2011-10-25 14:05 -0600
      Re: How to isolate a constant? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-10-25 17:08 -0700
        Re: How to isolate a constant? Mel <mwilson@the-wire.com> - 2011-10-25 22:48 -0400
      Re: How to isolate a constant? Ian Kelly <ian.g.kelly@gmail.com> - 2011-10-25 18:30 -0600
  Re: How to isolate a constant? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-10-22 17:55 -0700

csiph-web