Python 3 and PyQt 4 recommendations - pyqt

Is the combination of Python 3 and PyQt 4 recommended? Are there any alternatives?

I don't see why not, there is a version available for Python 3 which works normally, and the only alternative if you really need Qt would be PySide, which is far from being compatible with Python 3.
Other GUI alternatives would be wxPython (not in Python 3 yet AFAIK) and the "native" Tkinter (which is something else...).

If PyQt4 is the only non-native module you need, there should be no problem.
Check if all modules you need are available for Py3k!
PyQt4 for Py3k is not yet integrated into all distributions.
I.e. on Debian PyQt4 only works with Python 2 currently.
Have a look at 3to2! A tool to convert Py3 to Py2 code.
That is just better than coding in Py2 and using 2to3.

Related

Can I transpile python 3.7 code to a lower version?

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

What is the real current status of Twisted on Python3?

Had used some twisted using Python 2.6 few years back, and since then stopped using Python. Recently starting picking up on Python 3, and was checking status of twisted support for Python 3 which was very thin back when I left.
Introduction section of the Latest document on the topic says this:
Twisted is currently being ported to work with Python 3.4+. This
document covers Twisted-specific issues in porting your code to Python
3.
Most, but not all, of Twisted has been ported, and therefore only a
subset of modules are installed under Python 3. You can see the
remaining modules that need to be ported at
twisted.python._setup.notPortedModules, if it is not listed there,
then most of all of that module will be ported.
And clicking on the twisted.python._setup.notPortedModules shows no module listed.
Does that mean that twisted is now fully supported on Python 3 ? Or just the list is incorrect ? If so, are the samples / examples converted for Python 3 ?
The most likely definitive resource on this topic is the continuous integration system.
According to https://travis-ci.org/twisted/twisted, a recent run had 9957 passing tests on Python 3.6 compared to 9933 passing tests on Python 2.7. There is some slop in these numbers because the test suite includes some tests which are only relevant to Python 2.x and others which are only relevant to Python 3.x (therefore we would not expect exactly the same number of tests to run on each runtime) however these numbers are so close that I would say that Twisted has basically been complete ported to Python 3.6. Problems that remain are probably more likely to be "regular bugs" rather than unported code.

What is the difference between Python's unittest and unittest2 modules?

I currently work on some code that uses unittest2 module. I suspect this code was meant for the python2. Can one use python3 unittest as a drop in replacement for unittest2? What is the difference between the two?
According to the Python 2.7 unittest docs:
unittest2: A backport of new unittest features for Python 2.4-2.6 Many
new features were added to unittest in Python 2.7, including test
discovery. unittest2 allows you to use these features with earlier
versions of Python.
So moving from unittest2 under Python 2 to unittest under Python 2.7 or Python 3 should do exactly what you want

Are there any inbuilt GUI modules in python 3.4?

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.

Why doesn't pyGame or pyglet support python 3?

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.

Resources