Monday, 28 January 2013 13:58

Finally python3 allows short and descriptive variable names

Written by 
Rate this item
(0 votes)

python utf8

Many programmers including me like short variable names. We consider programming as an art where the source code is the paint and the screen is the canvas. However source code should be written as easy to understand as possible. This is because source code is almost never documented well enough. I believe that well written source code explains itself to the reader through variable, class, object and method names. Of course tricky parts should still be commented.

When looking for descriptive variable names you often end up with very long variable names, which when passed to long function names look rather ugly on the canvas. It came to my mind some years ago how interesting it would be to write software by using languages that can describe words with short characters like Japanese or Chinese. Some days ago I checked out the changes in Python 3 and surprisingly they do now support full Unicode variable names. I instantly upgraded my rasberry pi with python3 which was quite a hassle because python 2.x is still the standard many programs depend on. Once installed I wrote my first Chinese program, a Person class. The class has a constructor as well as the methods walk, run, sit and drink. When drinking you can pass a variable of what kind the person is drinking.

The screen shot above shows the source code in my favorite editor jed. The screen shot below shows the output of the program when executed.

Happy scripting.

Read 673 times Last modified on Friday, 26 June 2015 11:41

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.