Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111123
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How well do you know Python? |
| Date | 2016-07-05 21:50 +1000 |
| 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> |
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
Re: How well do you know Python? Chris Angelico <rosuav@gmail.com> - 2016-07-05 21:50 +1000
csiph-web