How to modify this from Python 2.x to v3.4?
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)] ... ... --- Best Regards, Jach Fong -- https://mail.python.org/mailman/listinfo/python-list
Re: How to modify this from Python 2.x to v3.4?
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
Need some help with Python Job Board
The Python Job Board could use a little help in a couple areas. One, we can always use help reviewing and approving (or rejecting) submissions. The backlog keeps growing, and the existing volunteers who help can't always keep up. (This is a good problem to have, reflecting on Python's broad popularity in many application domains.) Two, and perhaps more important, the submission form really needs to support WYSIWYG editing. Apparently, most posters are unable to handle markup-based systems, probably just pasting content from Word documents. Making this change would streamline the review process, as formatting problems are currently the biggest impediment to successful submissions. There is an open ticket to add this feature: https://github.com/python/pythondotorg/issues/655 If you can help with either task, please drop a note to j...@python.org. Thanks, Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Hide text in entry box when i click on it.(GUI using Tkinter in python)
Thanks it was helpful -- https://mail.python.org/mailman/listinfo/python-list
Re: How to modify this from Python 2.x to v3.4?
Ned Batchelder於 2017年11月11日星期六 UTC+8下午8時49分27秒寫道: > 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. Thank you, Ned. As I remember that I had opened a thread here last year, trying to use "2To3" tool to convert the ctypesgen package, but didn't success. https://groups.google.com/forum/#!topic/comp.lang.python/9G0FJXmtwbA This time, somehow I find this "ctypesgen-python-3" package and can't wait to give it a try, but is disappointed again. I suppose there are many v3.x users who like to use ctypesgen to ease the using of ctypes. But obviously, it's not an easy work to do, convert 2 to 3:-) By the way, does anyone know what the following codes does? (in printer.py file) and how to convert it to v3.x? class WrapperPrinter: def __init__(self,outpath,options,data): ... ... self.print_header() print >>self.file self.print_preamble() print >>self.file self.print_loader() print >>self.file ... ... --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: How to modify this from Python 2.x to v3.4?
On 11/11/2017 9:06 PM, jf...@ms4.hinet.net wrote: Ned Batchelder於 2017年11月11日星期六 UTC+8下午8時49分27秒寫道: 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. Thank you, Ned. As I remember that I had opened a thread here last year, trying to use "2To3" tool to convert the ctypesgen package, but didn't success. https://groups.google.com/forum/#!topic/comp.lang.python/9G0FJXmtwbA This time, somehow I find this "ctypesgen-python-3" package and can't wait to give it a try, but is disappointed again. I suppose there are many v3.x users who like to use ctypesgen to ease the using of ctypes. But obviously, it's not an easy work to do, convert 2 to 3:-) By the way, does anyone know what the following codes does? (in printer.py file) and how to convert it to v3.x? class WrapperPrinter: def __init__(self,outpath,options,data): ... ... self.print_header() print >>self.file print(file=self.file) # print blank line self.print_preamble() print >>self.file self.print_loader() print >>self.file ... ... --Jach -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: How to modify this from Python 2.x to v3.4?
On Saturday, November 11, 2017 at 8:07:06 PM UTC-6, jf...@ms4.hinet.net wrote: [...] > By the way, does anyone know what the following codes does? > (in printer.py file) and how to convert it to v3.x? > > class WrapperPrinter: > def __init__(self,outpath,options,data): > ... > ... > self.print_header() > print >>self.file > > self.print_preamble() > print >>self.file > > self.print_loader() > print >>self.file > ... > ... `print` was changed from a statement to a function, so it's just a matter of converting it to a function call. If you read the docs for the new print function, it should be relatively easy to translate. I don't understand why you're having so much trouble. https://docs.python.org/3/whatsnew/3.0.html?highlight=print#common-stumbling-blocks -- https://mail.python.org/mailman/listinfo/python-list