In a python-based project, I would like to use features data classes and libraries such as the current RxPY version.
However, we are bound to an environment (a Yocto-system) that only has Python 3.5.5
From TypeScript/JavaScript I know that some languages allow code to be transpiled to a lower language version.
Can Python 3.7 code be transpiled to a lower version?
Many thanks
You can't just use a tool to convert Python code to earlier versions, because those versions would sometime lack the libraries that you need. Using Python 3.7's dataclass is a good example.
A workaround for you would be to just install a port of dataclasses back in your 3.5 environment. This would be tricky. If you had python 3.6 you could just install this through
pip install dataclasses
But you can see in this issue that they never ported it back for python 3.5. If you check out their GitHub, maybe there are manual changes you could do to the source code to make it work. Maybe.
The easier way would be to find an alternative to dataclasses
Related
When publishing a package, I need to tell users which version of python they require. I've been developing against Python 3.6, but I don't know how far backwards compatible my code is (or my dependencies).
Is there a static analysis tool / version guide to help me figure this out?
I'm sure this is impossible to do with regard to 3rd party dependencies, but is there a static analysis tool that might help? This seems like the sort of thing pylint could help with, but it doesn't appear to.
This answer seems to imply I might set up, for example, a conda environment for each sub version of python 3, install and run pylint from each. Maybe that's the best I can do?
I know that python 3.6 is only available since a few days. What do you think when cx_Oracle for python 3.6 will become available?
I'm not a python expert. May I also ask why there is a dependency between the python minor version and the Oracle library?
thanks a lot, and have a great new year.
Juergen
The reason there is a dependency is because cx_Oracle is a C extension, which means that it must be compiled every time the Python C API changes. That generally happens each time a minor version is released. As to when cx_Oracle will be released for Python 3.6 -- that is unknown but hopefully will be soon! In the meantime you can compile it for yourself and use it before any official release is made.
I am learning python from a video tutorial series that uses a GUI called 'simpleGUI'.
It is not inbuilt in python so I had to download install a similar module called 'simpleGUITK'.
I'm new to python and I wish to know if there is any inbuilt module that I can import without any installation (like I important math or random) which is same as (or at least similar to) simpleguitk?
Because I might need to send some py files to a friend who might not be having the simpleguitk module.
To my knowledge there is no GUI module in the standard library. However, some, like Tkinter, are included with most Python distributions.
I strongly advise that you have a look at the GUI FAQ in the official documentation.
A standard build of python includes tkinter. From the GUI FAQ:
Standard builds of Python include an object-oriented interface to the
Tcl/Tk widget set, called tkinter. This is probably the easiest to
install (since it comes included with most binary distributions of
Python) and use. For more info about Tk, including pointers to the
source, see the Tcl/Tk home page. Tcl/Tk is fully portable to the Mac
OS X, Windows, and Unix platforms.
I have been looking into various game design modules for python such as pyglet and pyGame. I have noticed that both of these seem to only be compatible with python 2. Seeing as python 3 is the most current version, why is this? My experience with python has been with python 3, so are there good frameworks/modules out there for python 3 game development? Or would I be better off learning python 2 and using pyglet or pyGame?
edit: I would be using pyGame on a mac. The downloads page, http://www.pygame.org/download.shtml, only has links for py2.6, py2.5, and py2.4, which is what leads me to believe it is not python 3 compatible.
I don't even get your question, as PyGame is compatible with Python 3 since version 1.9:
http://www.pygame.org/wiki/python3porting?parent=todo
There are a few minor issues, but it is usable with Python 3.
I'm developing a pygame-based application on Mac OSX with python 3. It definitely works fine, and so far I haven't run into any compatibility problems, though there are certainly other mac-specific pygame bugs that I have found.
That said, I can definitely confirm that it works.
The fifth link from the top under "Windows" on the page you linked to clearly has py-3.1 in the name.
They don't support Python 3, because nobody has made them support Python 3 yet. It's a bizarre question. :-)
PyGame seems to mostly support Python 3. There are some issues: (from http://www.pygame.org/wiki/python3porting?parent=todo )
Complete unicode file name handling (fsencoding branch), then merge back into trunk (by mid Sept/10).
update documentation to explain Unicode in Pygame
work out final solution for open Python 3 IOBase objects: how to check abstract types from C. (Sept. 1, 2010) Probably the most practical solution is to just do duck typing.
_movie - deferred until module is ready for release
scrap (does some C string stuff that makes porting difficult)
camera - what is the status of this module?
Nowhere does it say that it doesn't work for Python 3 on mac, and it seems unlikely to that that this would be the case. So you can try, but you will have to compile it yourself.
Pyglet doens't mention Python 3, so it's probably not ported.
pyglet 1.2 (alpha as of July 2012) works with Python 3.
What are the current rules for writing python code that will pass cleanly through 2to3 and what are the practices that seem to be best suited to writing code that will not become mired forever in version 2.
I have read from the SciPy/NumPy forums that "100% test coverage" (unit testing) is important for many people, and I am not sure if that would apply to everybody. Certainly having a reasonable set of unit tests to try your code out with after conversion, seems a sane step.
Are there other things? What are skilled Pythonistas doing if they are writing 2.x code that they hope to have come through "cleanly" in the 2to3 process.
I am looking for specific instances of "[don't] do this" as well as some more general "best-practices", but specific instances of "do's and don'ts" are helpful.
Let's assume that frameworks, libraries (Django, SciPy/NumPy), and every other C Extension we need gets ported to Python3 eventually, and I'm asking about how you write and maintain the pure python language code that you write yourself.
Update: It's possible that what I really want is the "style guide" and list of deprecated features that everybody was already staying away from. I cut my teeth on Python 1.5 and moved to 2.0, and then have not really followed much of the 2.5/2.6 era, used them but really my code is more 2.1 era.
I'd say:
Read the "What's new for Python 3.0". Very informative.
In particular, if you care about Unicode or text encodings at all, take the time to understand what has changed for 3.x. That's probably one of the trickier things to change for Python 3.x.
Get Python 2.6 or 2.7, and run your code with the -3 flag. It will tell you about things in your code that will need changing.
Before using 3rd-party packages, check to see if they have a Python 3.x version. If not, check the package web site, mailing lists, version control repositories etc to see how actively the package is being developed and whether there is a roadmap towards Python 3.x support.
Download Python 3.x and try it out! Admittedly, that might not be practical if you care about code that currently depends on packages that don't yet support Python 3.x (e.g. wxPython or Django).