Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104028
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Any comment on using ctypesgen package? |
| Date | 2016-03-04 23:00 +1100 |
| Message-ID | <mailman.184.1457092816.20602.python-list@python.org> (permalink) |
| References | <3f342ec1-c6cd-49a8-aca2-2eac21fbbd79@googlegroups.com> |
On Fri, Mar 4, 2016 at 10:08 PM, <jfong@ms4.hinet.net> wrote: > Below is the troubled codes in file lex.py: > Note: In original codes (before 2To3 modify), there is "types.ObjectType" instead of "object". > --------- > # Available instance types. This is used when lexers are defined by a class. > # It's a little funky because I want to preserve backwards compatibility > # with Python 2.0 where types.ObjectType is undefined. > try: > _INSTANCETYPE = (types.InstanceType, object) > except AttributeError: > _INSTANCETYPE = types.InstanceType > class object: pass # Note: needed if no new-style classes present > ----------- > The author had put some comments above these codes but I have no idea what he is talking about. I'm not sure exactly what this is trying to do, but if it's just for isinstance testing, you can save yourself a lot of trouble. In Python 3, *every* type inherits from 'object'. So _INSTANCETYPE can be set to just object - and anything that's trying to query that can simply assume it's true. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Any comment on using ctypesgen package? jfong@ms4.hinet.net - 2016-03-04 03:08 -0800
Re: Any comment on using ctypesgen package? Chris Angelico <rosuav@gmail.com> - 2016-03-04 23:00 +1100
Re: Any comment on using ctypesgen package? Peter Otten <__peter__@web.de> - 2016-03-04 13:35 +0100
Re: Any comment on using ctypesgen package? jfong@ms4.hinet.net - 2016-03-04 21:35 -0800
Re: Any comment on using ctypesgen package? Chris Angelico <rosuav@gmail.com> - 2016-03-05 16:49 +1100
Re: Any comment on using ctypesgen package? jfong@ms4.hinet.net - 2016-03-05 00:14 -0800
Re: Any comment on using ctypesgen package? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-05 11:59 +0000
Re: Any comment on using ctypesgen package? jfong@ms4.hinet.net - 2016-03-06 16:57 -0800
csiph-web