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


Groups > comp.lang.python > #111123

Re: How well do you know Python?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: How well do you know Python?
Date Tue, 5 Jul 2016 21:50:31 +1000
Lines 39
Message-ID <mailman.95.1467719434.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> <CAPTjJmp3iMKN5D5yv7s+b8FUu5P7BdpD1eZ36dRGchrepiJfRw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de Wk8ZgRTEFw+cgAY7X9b2IwESew5n7yr03QSrUsd8sVCg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'classes,': 0.05; 'classes.': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'imports': 0.09; 'simplified': 0.09; 'subclass': 0.09; 'subtle': 0.09; 'python': 0.10; 'explicitly': 0.15; '2016': 0.16; 'a(object):': 0.16; 'bugs.': 0.16; 'distinct': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'new-style': 0.16; 'old-style': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'circular': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'affected': 0.22; 'pass': 0.22; '(or': 0.23; 'seems': 0.23; 'second': 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'script': 0.25; 'chris': 0.26; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'object,': 0.27; 'said,': 0.27; 'cat': 0.29; 'classes': 0.30; "i'd": 0.31; 'maybe': 0.33; 'run': 0.33; 'class': 0.33; 'problem': 0.33; 'foo': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'created': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'one,': 0.37; 'skip:p 20': 0.38; 'real': 0.62; 'jul': 0.72; 'chrisa': 0.84; 'otten': 0.84; 'subject:you': 0.85; 'to:none': 0.91; 'involved.': 0.91; 'subject:know': 0.91; 'refuse': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=5CFqytEnTRGMv77Cz+hcBIj9/JClyWyJPHqwnQfyR5U=; b=ueR7uh0olyDH6thMLuUTyVNL/eikWxFxpxzFbsB5bM6GQ0gWxW/D8edDYhKYmZ40cF WoTl/XeIEOy9JnBJHbvdx6I2EZoyxpFzokfTt886i2uRyz+hiCIsXNnQ/MQD+g1Fbo4T 1LiXHzw2hbjIEaRsk8gqRHTfmWqkkM1xYhD9uTy/YDdcAnOid31I1h2kfuXnHChQVejp y58wEWJVPdvj1T4Rym3Su25G5gpNRQajxjU3UGfC/vYi4aH72MqlgvhB51kOP0LCUN/K e4dmXSwanlMVNNxpxRbrTbAaH6BgrX9SctaimVM72XcHKVO7tfDnp3UDkkbYtfRDih4x 06Gg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=5CFqytEnTRGMv77Cz+hcBIj9/JClyWyJPHqwnQfyR5U=; b=i2lrUNcpwGbM8pGT9cp/KdPmyBc7UtMBpy1ZGQROFWGy8pmqyz6ijRSmOEAtwOvisN HiHlDhq0GsW8FYdFSGtpwkHDUHlZ2AYDijF0VaCgGydW3gT2wydpSER9N9moTqd6KJo4 Dwtz/dK39qXmmQh+clE80qmVOscC70hs4jOPFi06L062iVRzI5UuGB9KjdXmR/4MqG4g 0CahCWDDCHhfcAyS8KnjXbmjkRkUvMNcPeDuyKKoyze00jqtgmuoad4/5rKYuNBtxdh0 8zWhZnZ+93jRzSzLq4y7RSr59+MGAR2p0gDYArs8MIOrLX3CMueAAFVDWbJB9MgaHQgB e/Fw==
X-Gm-Message-State ALyK8tKDL/rxogiELpGkLIYkl64XgvYOjCkEY9B+SkVheW9ZJFsfF1ArQsDNHRQ/4sHy6T1me7GW74PF1b5GkA==
X-Received by 10.28.41.195 with SMTP id p186mr15938249wmp.41.1467719432226; Tue, 05 Jul 2016 04:50:32 -0700 (PDT)
In-Reply-To <nlg5ur$i9m$1@ger.gmane.org>
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 <CAPTjJmp3iMKN5D5yv7s+b8FUu5P7BdpD1eZ36dRGchrepiJfRw@mail.gmail.com>
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> <nlg5ur$i9m$1@ger.gmane.org>
Xref csiph.com comp.lang.python:111123

Show key headers only | View raw


On Tue, Jul 5, 2016 at 9:33 PM, Peter Otten <__peter__@web.de> wrote:
> 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.

Like I said, change the commands to "python3", or explicitly subclass
object "class A(object): pass", and then it'll be using new-style
classes.

The two distinct classes problem is a very real one, and comes of
circular (or not-technically-circular, as in the second case) imports.

ChrisA

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


Thread

Re: How well do you know Python? Chris Angelico <rosuav@gmail.com> - 2016-07-05 21:50 +1000

csiph-web