Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8698
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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; 'integer,': 0.09; 'object.': 0.09; 'am,': 0.13; 'wrote:': 0.15; '(1,': 0.16; '(2,': 0.16; '[])': 0.16; 'curiosity,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'orientation;': 0.16; 'set;': 0.16; 'subject:behavior': 0.16; 'subject:example': 0.16; 'subject:set': 0.16; 'method.': 0.16; 'object,': 0.16; '>>>': 0.16; 'received:74.125.82.174': 0.19; 'received:mail- wy0-f174.google.com': 0.19; 'header:In-Reply-To:1': 0.22; 'message-id:@mail.gmail.com': 0.28; 'object': 0.30; 'sun,': 0.30; 'changes': 0.31; 'chris': 0.32; 'does': 0.32; 'to:addr:python- list': 0.34; 'calling': 0.34; 'difference': 0.34; 'regardless': 0.34; 'integer': 0.35; 'but': 0.37; 'received:google.com': 0.38; 'subject:: ': 0.38; 'received:74.125.82': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.40; 'saqib': 0.84; 'subject:class': 0.84; 'by.': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dZ7snHFLO4EZPrFZXxixwWYPF9PbTU85PoEHINR/OD8=; b=h5nyJovcnzuaKNeAXL5fYvka5hPaQvyPftZpO7RtR0SF7NkjeoUD6GXXL1RIlhRKVq S1v8A6PtMbObi4bfdXGLR9YiyxHPIo0puIvb5s0NnskHHP9aaq8Ukv+lT4Lbo3oRbdel ExytXFCTtDh+FerpVLFtc+jeM9UmlKMccQOXY= |
| MIME-Version | 1.0 |
| In-Reply-To | <6441039f-f226-4632-8e74-2b6415bf914e@n28g2000vbs.googlegroups.com> |
| References | <2dc52e22-5c0f-4e24-8197-df616db1a42c@u2g2000yqb.googlegroups.com> <mailman.566.1309644846.1164.python-list@python.org> <6441039f-f226-4632-8e74-2b6415bf914e@n28g2000vbs.googlegroups.com> |
| Date | Sun, 3 Jul 2011 10:46:02 +1000 |
| Subject | Re: Inexplicable behavior in simple example of a set in a class |
| 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.571.1309653963.1164.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1309653963 news.xs4all.nl 21756 [2001:888:2000:d::a6]:44644 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8698 |
Show key headers only | View raw
On Sun, Jul 3, 2011 at 8:23 AM, Saqib Ali <saqib.ali.75@gmail.com> wrote:
> So just out of curiosity, why does it work as I had expected when the
> member contains an integer, but not when the member contains a set?
It's not integer vs set; it's the difference between rebinding and
calling a method. It's nothing to do with object orientation; the same
happens with ordinary variables:
>>> a=b=1
>>> a,b
(1, 1)
>>> a=2
>>> a,b
(2, 1)
>>> c=d=[]
>>> c,d
({}, [])
>>> c.append("Test")
>>> c,d
(['Test'], ['Test'])
But:
>>> c=['Foobar']
>>> c,d
(['Foobar'], ['Test'])
When you do a=2 or c=['Foobar'], you're rebinding the name to a new
object. But c.append() changes that object, so it changes it
regardless of which name you look for it by.
Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Inexplicable behavior in simple example of a set in a class Saqib Ali <saqib.ali.75@gmail.com> - 2011-07-02 14:59 -0700
Re: Inexplicable behavior in simple example of a set in a class Chris Rebert <clp2@rebertia.com> - 2011-07-02 15:14 -0700
Re: Inexplicable behavior in simple example of a set in a class Saqib Ali <saqib.ali.75@gmail.com> - 2011-07-02 15:23 -0700
Re: Inexplicable behavior in simple example of a set in a class Chris Rebert <clp2@rebertia.com> - 2011-07-02 16:25 -0700
Re: Inexplicable behavior in simple example of a set in a class Chris Angelico <rosuav@gmail.com> - 2011-07-03 10:46 +1000
Re: Inexplicable behavior in simple example of a set in a class Chris Rebert <clp2@rebertia.com> - 2011-07-02 18:07 -0700
Re: Inexplicable behavior in simple example of a set in a class Chris Angelico <rosuav@gmail.com> - 2011-07-03 11:14 +1000
Re: Inexplicable behavior in simple example of a set in a class Peter Otten <__peter__@web.de> - 2011-07-03 00:22 +0200
Re: Inexplicable behavior in simple example of a set in a class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-03 12:25 +1000
csiph-web