Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17273
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'distinct': 0.05; 'names.': 0.07; 'subject:object': 0.07; 'variable,': 0.07; 'expected.': 0.09; 'foo': 0.09; 'foo,': 0.09; 'top-level': 0.09; 'am,': 0.12; 'classes,': 0.13; 'case.': 0.15; 'circular': 0.15; 'behavior?': 0.16; 'chance?': 0.16; 'curious,': 0.16; 'failed.': 0.16; 'guessing': 0.16; 'instantiated': 0.16; 'it...': 0.16; 'sequence.': 0.16; 'subject: \n ': 0.16; 'subject:behavior': 0.16; 'worse,': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'this?': 0.19; 'thorough': 0.21; 'header:In-Reply-To:1': 0.22; 'somewhere': 0.23; 'statement': 0.23; 'changed': 0.23; 'dictionary': 0.23; 'module,': 0.23; 'cc:2**0': 0.24; 'creating': 0.25; 'loaded': 0.25; 'tests': 0.25; 'classes': 0.26; 'module': 0.26; "i'm": 0.26; 'import': 0.27; 'produced': 0.28; 'right.': 0.28; 'script': 0.28; 'generic': 0.29; 'worked': 0.29; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'class': 0.29; 'imported': 0.30; 'ran': 0.30; 'yesterday,': 0.30; 'anyone': 0.31; 'version': 0.32; 'header:User-Agent:1': 0.33; 'rather': 0.33; 'there': 0.33; 'curious': 0.34; 'keys': 0.34; 'subject:/': 0.35; 'uses': 0.36; 'two': 0.37; 'but': 0.37; 'run': 0.37; 'received:192': 0.37; 'another': 0.37; 'some': 0.38; 'went': 0.38; 'clearly': 0.39; 'else': 0.39; 'called': 0.40; "it's": 0.40; 'received:192.168': 0.40; 'difference': 0.40; 'your': 0.61; 'chain': 0.66; 'proved': 0.67; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'why?': 0.77; '09:34': 0.84; 'nathan': 0.84; 'items,': 0.91 |
| Date | Thu, 15 Dec 2011 10:08:51 -0500 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 |
| MIME-Version | 1.0 |
| To | Nathan Rice <nathan.alexander.rice@gmail.com> |
| Subject | Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports |
| References | <CAOFbRmKV9zSyzh=Vd4wc-x7F8S12h8u70BcJ6-HoyS2PZLVF7w@mail.gmail.com> |
| In-Reply-To | <CAOFbRmKV9zSyzh=Vd4wc-x7F8S12h8u70BcJ6-HoyS2PZLVF7w@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:MUmkdO/VnPP3vzHnujIeu2A77kCabr5xkMR7YFmEzzV oLL1NW3GVO+IDYzYZ5OaY/xR7QUH9QBzrq/+v5w/oUa03xSC+A XWvdvkqySaHvqV6q4AYNbedWYdlM+NWzdObx0ijcy6i9hgYVDr AyOLnXl4iKUaGPSpKOXxDRLOnAV/tplqqfpg05R5yk+WhTyQFr 4OW97pdUtC+0nEcyFgqd0zIjjfqFoyPK8Snu7Am+9qrS7hIh2k Ws47DsBqvghfvwF1B31/s+DHK+WyHnB15/WobZNofgNUS2rt2i VPJFT2oUBaGOgAOrRkMQHGDtE+oUoYcMS8jYAzu2HQPJG3HBf7 OJk1IRJOHwXQ1ffZLP0A= |
| Cc | python-list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| 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.3672.1323961742.27778.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1323961742 news.xs4all.nl 6969 [2001:888:2000:d::a6]:41734 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17273 |
Show key headers only | View raw
On 12/15/2011 09:34 AM, Nathan Rice wrote: > I just ran into this yesterday, and I am curious if there is a > rational behind it... > > I have a class that uses a dictionary to dispatch from other classes > (k) to functions for those classes (v). I recently ran into a bug > where the dictionary would report that a class which was clearly in > the dictionary's keys was giving a KeyError. id() produced two > distinct values, which I found to be curious, and > issubclass/isinstance tests also failed. When I inspected the two > classes, I found that the only difference between the two was the > __module__ variable, which in one case had a name relative to the > current module (foo), and in another case had the fully qualified name > (bar.foo). When I went ahead and changed the import statement for the > module to import bar.foo rather than import foo, everything worked as > expected. My first thought was that I had another foo module in an > old version of the bar package somewhere on my pythonpath; After a > thorough search this proved not to be the case. > > Has anyone else run into this? Is this intended behavior? If so, why? > > Nathan Hard to tell with such generic information. But I'm guessing you imported your script from some other module, creating a circular import sequence. The circular can be a problem in its own right. But even worse, if the script is part of the chain is that it's loaded twice, with different names. And any top-level items, such as classes, will be instantiated twice as well. is your script called foo.py by any chance? -- DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports Dave Angel <d@davea.name> - 2011-12-15 10:08 -0500
csiph-web