[docs] bugs and suggestion

shoaib Mirzaey shoaib_mi at yahoo.com
Wed Jul 17 11:07:17 EDT 2019


As someone who spent almost two year creating application(GUI) in python I found plenty of issues which killing passion for doing morecoding in python. Fortunately lots of them are libraries issues and has nothingto do with python itself. But it has effect on decision of people to use pythonmore.

I can code in C, C++, Pascal, PHP, HTML, Python, and thereis no need to say that python is the best and most comfortable one.

At first I was using python 2.7 and it was very good, untilI started to use utf-8 encoding text in code

Then after a year struggling and overcoming Unicode issues,I got tired and decided to change the version of python to 3.6 to see how ittreats Unicode, and it was perfect. I wondered why you keep supporting python2.7 anymore when almost everything is the same in python 3.6.

Then I started to develop GUIs in python 3.6, and everythingwas great until I decided to compile it for windows users; running same code inwindows 7 64bit was really tricky. Here I enlist some tricks or bugs that camein my way, plus some suggestion:

1.      Version-dependency: 

With Windows 7 64bit, Python: v3.6 wesimply cannot install library pygobject through pip (or any other methods), itstuck in installing another dependency named pycairo, and even if we manuallyinstall it, and then install pygobject it will not find it, and tries toinstall it again; or maybe it’s because of version mismatch. I know that it’slibraries developer’s problem, but inside this problem lies a great pythonproblem, which is version dependent libraries. Of course it’s not only relatedto python. Even Linux OS has the same problem. Look at windows OS. If in year2000 someone has created an app working in windows 98, it still can beinstalled in windows 10. Why Linux or library developers do not care about thisproblem? I know that being update is so important and make distribution oflanguage and libraries smaller and easier. But there must be a way to force developersto remove previously written libs and change it to new one. For example, wecould define functions in python 2.7 in this way 

def some_function(a, b, (c, d))

but it’s not possible in python 3.x, whichI think it is better not to do that, but some developers didn’t develop theirlibs in python 3.x, just stop supporting python 2.7 and they will be forced tochange the code to compatible with python 3.x.

all I wanted to say is why the libs areversion-dependent? It’s really painful.

2.      Third party apps:

One more thing about above is that forrunning pygobject with python 3.x in windows we have to install msys2 ormingw64 and install all libraries we want inside mingw64, using pip in parallelwith pacman will cause conflicts. The thing is why we should install thirdparty software to run python libraries inside windows when we can simplyinstall it without them. So there must be a problem I don’t know maybe in dllfiles needed for python or libraries to work perfect; because pygobject isworking just fine with python 3.x in Linux platform.

3.      Right to Leftlanguage support:

There are some libraries to change thesituation in a way that developers could use RTL developing in their apps, butcomparing to visual studio we see that the language itself take care of that,and it automatically select right glyph (or character code) based on positionof character inside word, and writes the word perfectly, but in python (anyversion) it writes characters (with unappropriated glyph) from left to right(which must be reversed). If you could take care of that in the core of python,everyone in the world would appreciate it including me.

4.      exec and execfile: 

in python 2.7 there was a built-in functionexecfile which has very simple syntax and easy to use and understandable, andsuddenly you have removed it and forced everyone to use a little bit complexmethod exec(open(‘filename.py’).read()).I am saying that it wasn’t a good toremove it, because finally the languages must be much more user friendly andeasy to learn.

There is one more problem with exec() andI’ll show it through images (I didn’t examin execfile in py2.7 for thissituation). it’s not libraries bugs, it’s python’s bug.

It doesn’t matter we use kivy or PyQt5 orGtk as our graphical user interface the result is the same.

When developing big apps, we need toseparate code in (.py) files and call them in main code to run. There areseveral methods for do so. Let’s first use exec():

main.py content:


page2.py content

    from PyQt5.QtWidgets import *    class HelloWindow(QWidget): def __init__(self): QWidget.__init__(self) self.setWindowTitle("وه شه نی گیان") gridLayout = QGridLayout(self)      self.title = QLabel("قوربانه ت")  gridLayout.addWidget(self.title, 0, 0) self.setLayout(gridLayout)    app = QApplication([])    mainWin = HelloWindow()    mainWin.resize(400,200)    mainWin.show()    app.exec_()
If we run page2.py the result is perfect. but if we run main.py the GUI can not handle unicode text inside widgets. At first I thought it’s libraries problem, then I tested the sameprocedure with kivy GUI, and result was the same.But there is something else, if we changemain.py as:    import page2
everything is perfect again. That’s why Igot convinced it was a bug in python itself.

The real reason why I prefer use of<exec()> over <import> is that exec() uses everything that isimported before, but <import> forces me to reimport every libraries Ihave imported before in every scripts I have, and that’s double working, and Idon’t know if it consume more RAM or not; it’s not preferable.

And something else, can you please makechanges to <import> method so it can run without reimporting other previouslyimported modulus. I am aware that you did that to modulus to be independent. 

5.      Static Arrays:

Python is very good in dealing with arrays,actually it’s perfect. It can save several types of data inside one array, andeach time we can change value and type of array’s elements, and it’sincredible. But there are some times that having dynamic arrays is prolongingduration of running code; for example, if we are going to do mathematicalcalculation and we know that every element of the array is a float number andit occupies fixed size inside RAM, so there is no need to recomputing the newsize in each change of array’s elements. If you could define new method fordealing with this situation, that makes it much efficient in math jobs.

I am not aware if numpy or other librariescould do this, but if it’s inside the python, it would be much better. 

Lately I changed a code written in Pascalinto python. It was computing second order differential equation numerically.Run time of Pascal code was almost 9 seconds while the python code inside Linux,took 100 seconds and inside windows 190 seconds. I don’t know how arrays aredealt with in python, but I thought maybe it’s because the arrays are dynamicin python and if we have had static arrays, duration must be almost the sameorder.

6.      Code Editor:

Writing code inside a lovely editor withcolor code and suggesting codes is always preferable, if it’s possible add agood editor with mentioned ability and stylable to python 

7.      Hiding code oncompile:

When we are using pyinstaller compiling thecode, it makes it independent of OS to run, and it’s a good thing, but I’veread in web that the code can be decompiled from packaged app. If you couldmake the compiler to hide or encrypt code automatically, then we were almostsure that our code cannot be reused without permission. I know that cython cando this but it’s better if it was default python behavior.

Thank you for creating such a great programing language.

Sincerely yours

Shoaib Mirzaei

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190717/44143a7b/attachment.html>

More information about the docs mailing list