On 11/11/17 6:56 AM, jf...@ms4.hinet.net wrote:
I learned python start from using v3.4 and never has any v2.x experience. There is a Pypi 
project "ctypesgen" I like to use, but it seems is for v2.x. (un)Fortunately I 
found one of its branch on github which announced is for Python3, but strangely it still 
use some v2.x words, for example, print. Its last update was at July 2009, maybe at the 
early age of v3? The one below which I can't figure out how to modify. Can someone show 
me the answer? (I don't want to spend time on learning the old history:-)

---------------------
# 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, types.ObjectType)
except AttributeError:
    _INSTANCETYPE = types.InstanceType
    class object: pass       # Note: needed if no new-style classes present
...
...
...
     if module:
         # User supplied a module object.
         if isinstance(module, types.ModuleType):
             ldict = module.__dict__
         elif isinstance(module, _INSTANCETYPE):
             _items = [(k,getattr(module,k)) for k in dir(module)]


This looks like fairly advanced code.  It will be difficult to port to Python 3 *without* understanding some of the old history.  There seem to be forks on GitHub, including one with a pull request about Python 3 made in the last few days: https://github.com/davidjamesca/ctypesgen/pull/58 .  I'd recommend working with others on this.

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to