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


Groups > comp.lang.python > #111122

Re: How well do you know Python?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: How well do you know Python?
Date Tue, 05 Jul 2016 13:33:42 +0200
Organization None
Lines 31
Message-ID <mailman.94.1467718436.2295.python-list@python.org> (permalink)
References <CAPTjJmoZobGYDh8jWDPPWQqoN-gid+-HUp9-dtKX_Vp=BgHc+w@mail.gmail.com> <nlfrhl$bq1$1@ger.gmane.org> <CAPTjJmqn_asKVPpLwTQFWCSXe3w6hxQdXxXnfznZ6ucJO0yrsw@mail.gmail.com> <nlg5ur$i9m$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de hthPq98yNSwdQFCcdCegcw9kTQLCJRXIPjvLYzT/ixMQ==
Return-Path <python-python-list@m.gmane.org>
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; 'subject:Python': 0.05; 'classes,': 0.05; 'classes.': 0.07; 'subject:How': 0.09; 'imports': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'simplified': 0.09; 'subclass': 0.09; 'subtle': 0.09; 'python': 0.10; 'explicitly': 0.15; '2016': 0.16; 'bugs.': 0.16; 'distinct': 0.16; 'old-style': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.16; 'circular': 0.18; 'affected': 0.22; 'pass': 0.22; 'seems': 0.23; 'import': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'chris': 0.26; 'question': 0.27; 'object,': 0.27; 'cat': 0.29; 'classes': 0.30; "i'd": 0.31; 'maybe': 0.33; 'run': 0.33; 'class': 0.33; 'foo': 0.33; 'tue,': 0.34; 'but': 0.36; 'there': 0.36; 'created': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'skip:p 20': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'jul': 0.72; 'otten': 0.84; 'subject:you': 0.85; 'involved.': 0.91; 'subject:know': 0.91; 'refuse': 0.93
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd86ae.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <nlg5ur$i9m$1@ger.gmane.org>
X-Mailman-Original-References <CAPTjJmoZobGYDh8jWDPPWQqoN-gid+-HUp9-dtKX_Vp=BgHc+w@mail.gmail.com> <nlfrhl$bq1$1@ger.gmane.org> <CAPTjJmqn_asKVPpLwTQFWCSXe3w6hxQdXxXnfznZ6ucJO0yrsw@mail.gmail.com>
Xref csiph.com comp.lang.python:111122

Show key headers only | View raw


Chris Angelico wrote:

> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__peter__@web.de> wrote:
>> What will
>>
>> $ cat foo.py
>> import foo
>> class A: pass
>> print(isinstance(foo.A(), A))
>> $ python -c 'import foo'
>> ...
>> $ python foo.py
>> ...
>>
>> print?
> 
> I refuse to play around with isinstance and old-style classes.
> Particularly when circular imports are involved. Run this under Python
> 3 and/or explicitly subclass object, and then I'd consider it. :)

The intended lesson was that there may be two distinct classes

__main__.A and foo.A

Even though not just classes, but every object created in the script is 
affected this seems to cause the most subtle bugs.

Maybe the setup can be simplified or the question rephrased to make this 
clearer.

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


Thread

Re: How well do you know Python? Peter Otten <__peter__@web.de> - 2016-07-05 13:33 +0200

csiph-web