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: References: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:111122 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.