Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26858
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.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; 'subject:: [': 0.03; 'function,': 0.07; 'subject:question': 0.08; 'assigning': 0.09; 'def': 0.10; 'aug': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'one-element': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; '>>>': 0.18; 'subject:] ': 0.19; 'received:209.85.214.174': 0.21; 'modifying': 0.22; 'header :In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'chris': 0.28; 'pointer.': 0.29; 'probably': 0.29; 'fri,': 0.30; 'subject:lists': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'returning': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'level.': 0.36; 'level': 0.37; 'why': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'worth': 0.63; 'world': 0.63; 'wanting': 0.65 |
| 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 :content-type; bh=JOrohitDBjn0d66ldKpN28laJEE8ZEv/1ov3RaQhia8=; b=TIe4CnBZTBadw+aUI1oexI60X+OJBolpa51fDnIfHLm+rxqjDE1e/beYsvCT8kICFp CU83G/0p5R/NQaugUL2rgCmPySkD1GW7ZuPku0lqWGMdcKFwQ6vciYW9hu0xNaaN4etR dJIC3Oxz2yssk1bPJyAdbD9IMaBS3IFb6+cDlZYCy23d3PKvk8PYlmnL02Aiy7h9tfRZ ZTRPN5O+MFCNtSz6KTg4/PxwnTmYLG79wxt0DYru7yIuiTdqHMiogtwC0lGHBvbFJfLl h7Xvs3k8P1nVrhxIDC6sGXOT7LekJEeGjhZE8RO1GI60dM+kXUThMbaKkYqZuux+iBeG 1D+Q== |
| MIME-Version | 1.0 |
| In-Reply-To | <k02nt5$r8p$1@news.albasani.net> |
| References | <k02jn0$id2$1@news.albasani.net> <mailman.3150.1344593295.4697.python-list@python.org> <k02nt5$r8p$1@news.albasani.net> |
| Date | Fri, 10 Aug 2012 20:40:01 +1000 |
| Subject | Re: [newbie] A question about lists and strings |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.3153.1344595204.4697.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344595204 news.xs4all.nl 6920 [2001:888:2000:d::a6]:57957 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26858 |
Show key headers only | View raw
On Fri, Aug 10, 2012 at 8:31 PM, Mok-Kong Shen <mok-kong.shen@t-online.de> wrote: > This means there is no way of modifying a string at the top level > via a function, excepting through returning a new value and assigning > that to the string name at the top level. Please again correct me, if > I am wrong. Yes, but you can (ab)use a one-element list as a pointer. >>> foo=["Hello"] >>> def mutate(ptr): ptr[0]="World" >>> mutate(foo) >>> print(foo[0]) World But it's probably worth thinking about exactly why you're wanting to change that string, and what you're really looking to accomplish. There may well be a better way. Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 11:19 +0200
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:28 +0400
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:48 +0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:12 +0200
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:37 +1000
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:37 -0400
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 14:56 +0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 13:08 +0200
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:56 -0400
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 21:00 +1000
Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 15:06 +0400
Re: [newbie] A question about lists and strings Peter Otten <__peter__@web.de> - 2012-08-10 11:59 +0200
Re: [newbie] A question about lists and strings Rotwang <sg552@hotmail.co.uk> - 2012-08-10 16:12 +0100
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:07 -0400
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:31 +0200
Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:40 +1000
Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:48 +0200
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:58 -0400
Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:53 -0400
csiph-web