concept Python in category apache thrift

This is an excerpt from Manning's book Programmer's Guide to Apache Thrift.
The number of programming languages in common commercial use has grown considerably in recent years. In 2003, 80% of the Tiobe Index (http://www.tiobe.com/index.php/tiobe_index) was attributed to six programming languages: Java, C, C++, Perl, Visual Basic, and PHP. In 2013, it took nearly twice as many languages to capture the same 80%, adding Objective-C, C#, Python, JavaScript, and Ruby to the list (see figure 1.1). In early 2016 the entire Tiobe top 20 didn’t add up to 80% of the mind share. In Q4 2015, Github reported 19 languages all having more than 10,000 active repositories (http://githut.info/), adding Swift, Go, Scala, and others to the list.
In this section, we look at installing Python and working across Python versions 2 and 3. The key features of Apache Thrift Python are covered in chapters 1 through 10 of this book, Python being one of our three demonstration languages in part 2.
Python has two active major versions, Python 2 and 3. Version 2 is fading away and is officially end of life in 2020, so you may find it more convenient to code new Apache Thrift applications in version 3.
Apache Thrift supports both major versions of Python. Several key incompatibilities impact Apache Thrift across Python 2 and 3, especially changes in support for strings and binary data. Fortunately, the Python six library provides a cross-platform interface to the problem features.
Apache Thrift libraries for Python are available through the standard Python package manager, Pip. Pip may not be installed on your system, but it’s easy to add. For example, on Ubuntu 16.04 you can install Pip for Python 2.x and Python 3.x:
The previous command installs Thrift for Python 2, because we used the Python 2 version of Pip. To run our Hello World Python example (also demonstrated in chapter 1) under Python 2, we can gen stubs and run the server directly:
~/thriftbook/part3/script/python$ thrift -gen py ../hello.thrift ~/thriftbook/part3/script/python$ python hello_server.py [Server] Started [Server] Handling client request: worldTo test the server with a client, we can run the client under Python 2 in another shell:
~/thriftbook/part3/script/python$ python hello_client.py [Client] received: Hello worldHowever, we can also run the client under Python 3 by installing Thrift with Pip 3:
~/thriftbook/part3/script/python$ pip3 install thrift Collecting thrift Using cached thrift-0.10.0.zip Collecting six>=1.7.2 (from thrift) Using cached six-1.10.0-py2.py3-none-any.whl Building wheels for collected packages: thrift Running setup.py bdist_wheel for thrift ... done Stored in directory: /home/user/.cache/pip/wheels/e7/f1/d3/b472914d95caa1781fb29b1257 b85808324b0bfd1838961752 Successfully built thrift Installing collected packages: six, thrift Successfully installed six-1.10.0 thrift ~/thriftbook/part3/script/python$ python3 hello_client.py [Client] received: Hello worldIn the previous session, we installed the Python 3 Thrift library and ran the same client program used above with Python 2 under Python 3. Writing cross-version-compatible Python RPC code is fairly easy: as you can see from the example, Apache Thrift often takes care of all the details.