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


Groups > comp.lang.python > #33181 > unrolled thread

Re: Strange object identity problem

Started by"F.R." <anthra.norell@bluewin.ch>
First post2012-11-12 14:40 +0100
Last post2012-11-13 08:08 +0100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#33181 — Re: Strange object identity problem

From"F.R." <anthra.norell@bluewin.ch>
Date2012-11-12 14:40 +0100
SubjectRe: Strange object identity problem
Message-ID<mailman.3586.1352727727.27098.python-list@python.org>
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
>

[toc] | [next] | [standalone]


#33192

Fromduncan smith <buzzard@invalid.invalid>
Date2012-11-12 17:02 +0000
Message-ID<50a12baa$0$12377$a8266bb1@newsreader.readnews.com>
In reply to#33181
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

[toc] | [prev] | [next] | [standalone]


#33223

From"F.R." <anthra.norell@bluewin.ch>
Date2012-11-13 08:08 +0100
Message-ID<mailman.3612.1352790504.27098.python-list@python.org>
In reply to#33192
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web