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


Groups > comp.lang.python > #33223

Re: Strange object identity problem

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <anthra.norell@bluewin.ch>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'restarting': 0.07; 'space.': 0.07; 'loop.': 0.09; 'restarted': 0.09; 'clash': 0.16; 'idle.': 0.16; 'paused': 0.16; 'received:195.186': 0.16; 'received:bluewin.ch': 0.16; 'subject:object': 0.16; 'wrote:': 0.17; 'integer': 0.17; "shouldn't": 0.17; '>>>': 0.18; 'followed': 0.20; 'error.': 0.21; '(b)': 0.22; 'exists.': 0.22; 'focusing': 0.22; 'keys': 0.22; 'subject:problem': 0.22; 'cheers,': 0.23; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'reflect': 0.27; "doesn't": 0.28; '>>>>': 0.29; 'subsequently': 0.29; 'that.': 0.30; 'year,': 0.30; 'more,': 0.32; 'print': 0.32; 'idle': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'thanks': 0.34; 'robert': 0.35; 'pm,': 0.35; 'there': 0.35; "didn't": 0.36; 'should': 0.36; 'beyond': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'range': 0.60; 'most': 0.61; 'first': 0.61; 'repeat': 0.62; 'strange': 0.62; 'it!': 0.64; 'received:ch': 0.69; 'obvious': 0.71; 'smith': 0.71; '2013': 0.84; 'occasion': 0.84; 'presumably': 0.84; 'realm': 0.84
Date Tue, 13 Nov 2012 08:08:16 +0100
From "F.R." <anthra.norell@bluewin.ch>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Strange object identity problem
References <50A0F5A8.4080802@bluewin.ch> <CA+mXAjLr=gNz1fVNTXrF_+EB-oGY1ZDLrzficg5N=oJpDj2jeg@mail.gmail.com> <mailman.3586.1352727727.27098.python-list@python.org> <50a12baa$0$12377$a8266bb1@newsreader.readnews.com>
In-Reply-To <50a12baa$0$12377$a8266bb1@newsreader.readnews.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 <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.3612.1352790504.27098.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352790504 news.xs4all.nl 6977 [2001:888:2000:d::a6]:44717
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33223

Show key headers only | View raw


On 11/12/2012 06:02 PM, duncan smith wrote:
> On 12/11/12 13:40, F.R. wrote:
>> On 11/12/2012 02:27 PM, Robert Franke wrote:
>>> Hi Frederic,
>>>
>>> [...]
>>>
>>>>>>> bas = {}
>>>>>>> for year in range (2010, 2013):
>>>>      ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year)
>>>>      ba.run ()
>>>> print year, id (ba)
>>>>      bas [year] = ba
>>>>
>>>> 2010 150289932
>>>> 2011 150835852
>>>> 2012 149727788
>>>>
>>>>>>> for y in sorted (bas.keys ()):
>>>>      b = bas [year]
>>> Shouldn't that be b = bas[y]?
>> Yes, it should, indeed! What's more, I should have closed and restarted
>> IDLE. There must have
>> been a name clash somewhere in the name space. The problem no longer
>> exists. Sorry
>> about that. And thanks to all who paused to reflect on this non-problem.
>> - Frederic.
>>
>>>
>>>
>>>>      print y, id (b)
>>>>
>>>> 2010 149727788
>>>> 2011 149727788
>>>> 2012 149727788
>>>>
>>> [...]
>>>
>>> Cheers,
>>>
>>> Robert
>>>
>>
>
> The problem was that year was bound to the integer 2013 from the first 
> loop. When you subsequently looped over the keys you printed each key 
> followed by id(bas[2013]). Restarting IDLE only helped because you 
> presumably didn't repeat the error.
>
> Duncan
>
That's it! Isn't it strange how on occasion one doesn't see the most 
obvious and simple mistake, focusing beyond the realm of foolishness. 
Thanks all . . .

Frederic

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


Thread

Re: Strange object identity problem "F.R." <anthra.norell@bluewin.ch> - 2012-11-12 14:40 +0100
  Re: Strange object identity problem duncan smith <buzzard@invalid.invalid> - 2012-11-12 17:02 +0000
    Re: Strange object identity problem "F.R." <anthra.norell@bluewin.ch> - 2012-11-13 08:08 +0100

csiph-web