Python Tools and Software

This topic was published by and viewed 1979 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    Python is a popular cross-platform scripting language. This means Python code can be used on many operating systems and architectures. Understanding Python implementations can help developers with their projects. Also, many people get confused by the many Python implementations and consoles, so I will also discuss some consoles and implementations to help give readers a better understanding of some of this Python software.

    Versions

    Many people may here about Python2 and Python3. Python2 is the older version that has long-term support. Python3 is the newest version. The two differ a little in syntax and available commands. In general, developers should use Python3 when designing a program.

    • Python2 Hashpling
      • #!/usr/bin/env python
      • #!/usr/bin/env python2
    • Python3 Hashpling
      • #!/usr/bin/env python3
    • Python3.4 Hashpling (specify minor release)
      • #!/usr/bin/env python3.4

    Users can run the Python2 interpreter in a terminal by typing "python", "python2", "python2.7", etc. to run Python2. Alternately, users can use Python3 by typing "Python3" or specifying a specific version. Typing "Python2" or "Python3" will run the latest version of Python2 or Python3, respectively. Yes, users may have multiple Python releases installed on their system with other releases and not have conflicts or errors arise (https://www.python.org/).

    python-versions
    python-versions

    Users can run executable Python scripts by clicking them like a normal executable as long as the script uses a proper hashpling and the executable-bit in permissions is turned on (enabled). Alternately, users can execute scripts in a terminal by typing something like one of the lines below (type the correct Python command for your script). Or, if the script has a proper hashpling and execute permissions, treat it like a normal executable (./script.py).

    python -c /SCRIPT/PATH.py
    python2 -c /SCRIPT/PATH.py
    python3 -c /SCRIPT/PATH.py

    Consoles

    Some Python consoles exist. These are like terminals dedicated to Python. IPython is an interactive Python console that offers various tools for testing the Python code (http://ipython.org/). IPython is also used for displaying plots and charts via matplotlib. IPython is available for Python 2 and 3.

    ipython
    ipython

    IDLE (Integrated DeveLopment Environment) is a lot like IPython, but with less features, but still enough to satisfy the needs of many developers. IDLE is available for both versions of Python.

    idle-python
    idle-python

    Bpython (http://bpython-interpreter.org/) looks like a terminal, but it has many more features than running Python in a shell-terminal. Bpython only supports Python3.

    bpython
    bpython

    Dreampie (http://www.dreampie.org/) is another Python console, and it is a lot like Bpython. However, Dreampie supports Python 2 and 3.

    dreampie
    dreampie

    Pycrust is yet another console. Pycrust typically comes as part of a package called "Py". Py is a collection of tools for wxPython development (http://www.wxpython.org/py.php). It is possible to find a stand-alone Pycrust program.

    Implementations

    Many implementations of Python exist (https://wiki.python.org/moin/PythonImplementations), but what do I mean by that? Well, there is other software that supports the Python programming language, but they have extra features or a different way of working. "Python" is the language, and an implementation is the interpreting environment. When users execute a standard Python script or use the "python*" commands in a terminal, they are using the CPython implementation (not to be confused with Cython). In other words, using the terminal-based interpreter executes code in the CPython environment. Most of the Python code people execute is processed in the CPython implementation. Each implementation has its uses and unique features.

    CPython is the default implementation, environment, or interpreter (which ever term you prefer). Scripts are typically executed in this interpreter. CPython is the official Python interpreter and is often referred to as the "reference implementation" since it follows the Python language specifications completely. CPython is written in C and converts the Python code to bytecode on execution of the code. Thus, CPython is a bytecode interpreter. When users download and install Python from the official website or from a software repository (like "apt-get" or "yum"), they are installing the CPython interpreter.

    NOTE: Often times, the term "implementation" and "interpreter" are used interchangeably.

    PyPy (http://pypy.org/) is an implementation that is a lot like CPython, but the interpreter itself is written in Python. Yes, the developers of this interpreter wrote a Python interpreter in Python. However, the code for the interpreter is converted to C and then compiled. PyPy is supposed to perform faster than CPython. While CPython converts interpreted code to bytecode, PyPy converts code to machine-code.

    NOTE: Machine-code is a set of instructions executed by the computer's CPU directly. Most programming languages are compiled to machine-code like when developers use gcc (or some other compiler) to compile their C-code to make a binary executable. Bytecode is an instruction set that is read by the interpreter and then the interpreter tells the CPU what to do. Such interpreters are often called virtual-machines, runtime-environments, or just-in-time (JIT) compilers.

    Psyco is an old interpreter that was a lot like PyPy. PyPy has taken the place of Psyco. When possible, use PyPy instead of Psyco.

    Jython (http://www.jython.org/) is an implementation written in Java. Jython allows developers to write Python code, but use Java libraries in addition to Python libraries (modules). Jython can be used as a just-in-time compiler, meaning the Python code is converted to Java bytecode (not Java source code) on runtime and then executed by the Java Runtime Environment (JRE). Alternately, programmers can have Jython compile the Python code to a jar file. The jar is then a standard jar file that users can run like any other jar file. This allows Python programmers to make Java programs. However, such programmers need to at least know about the available Java libraries, but then the programmers can still use Python's usual syntax. As a jar file, the usual Java runtime environment executes the code. Also, users can use Jython in a terminal by typing "jython", or some Python consoles can be set to use Jython instead of CPython. Python scripts that are intended for Jython use a different hashpling than normal scripts (#!/usr/bin/env jython). Jython is compatible with Python2.

    NOTE: Users can also use OpenJDK instead of Oracle's Java runtime environment (JRE). OpenJDK is an open-source JRE.

    jython
    jython

    IronPython (http://ironpython.net/) is an implementation written in C# for the .NET framework and Mono. IronPython is compatible with Silverlight and can be executed in web-browsers when used with Gestalt (http://gestalt.codeplex.com/ && http://visitmix.com/work/gestalt/). IronPython is Python2 compatible. However, CPython and IronPython operate differently causing rare instances where code may work on one implementation, but not the other.

    NOTE: Mono is an open-source framework that offers .NET-compatible tools.

    CLPython (http://common-lisp.net/project/clpython/) is a deprecated implementation written in Common Lisp. It once allowed Python code and Common Lisp code to be mixed as well as libraries from both languages. Python 2 was supported.

    PyS60 (Python for S60) is a deprecated implementation that was a port for Nokia's S60 platform.

    ActivePython (http://www.activestate.com/activepython) is an implementation that is CPython distributed with some extra extensions. ActivePython is distributed by ActiveState. This implementation is Python2 and 3 compatible.

    Cython (not CPython) is an implementation that allows Python to be converted to C/C++ code (http://cython.org/). Cython is also a dialect of Python (discussed later). Developers can also use Cython to execute Python scripts resulting in faster execution than CPython. In addition, developers can make a Python script and use Cython to create a compiled library file (*.so on Unix or *.dll on Windows) that can be used as a Python module. Cython scripts usually use the *.pyx file-extension. The "setup.py" files that are commonly associated with Cython are like "Makefiles" for C/C++ source code. Cython is Python 2 and 3 compatible.

    NOTE: Python modules and libraries are the same thing, just different names.

    As mention above, Cython is an implementation fully compatible with the Python 2 and 3 languages. However, Cython is also a dialect of Python. A dialect computer language is a computer language (in this case Cython) still belonging to a particular language (in this case Python). However, the dialect has some minor variations. Dialects may have less or more features or commands. Scripts for the Cython interpreter can be written using Python code, or developers can use some Cython specific features which allow the code to be more easily and efficiently converted to C/C++ code. Using more Cython-specific code will very likely make the resulting program execute more swiftly and efficiently compared to the CPython or Cython interpreter reading Python code. Other Python dialects include RPython (used to write PyPy) and Stackless-Python.

    QPython (http://qpython.com/) is an Android port of the CPython interpreter. QPython comes with the Android module for Python (import android). QPython can be found on Google Play.

    Kivy (http://kivy.org) is an open-source framework (with a Python interpreter) that runs on Android, iOS, Windows, Linux, MeeGo, Android SDK, and OS X. Python3 is supported and the developers are working with Cython 3.

    SL4A (Scripting Layer for Android) is a compatibility layer that allows Android to execute various scripting languages. SL4A has various parts and the part we are interested in is "Py4A" (Python for Android). Py4A is a form of CPython for Android.

    Various other implementations exist as well as many forks and ports of the different implementations. For example, WPython is a derivative of CPython that uses wordcode rather than bytecode (wordcode uses 16-bits instead of 8-bits). DSPython is another derivative of CPython; this one is for Nintendo's DS-console.

    Many Python implementations exist, each with a special purpose or feature. Developers interested in Python can learn about many more implementations at (https://wiki.python.org/moin/PythonImplementations). For those of you eager to learn Python, you can read the documentation for Python2 (https://docs.python.org/2/) or Python3 (https://docs.python.org/3/). For those of you that already know Python, you can strengthen your skills with Cython (http://docs.cython.org/) and RPython (http://pypy.readthedocs.org/en/latest/getting-started-dev.html).

    Understanding the different implementations can greatly sharpen a Python-scriptwriter's skills and abilities as well as help general computer users have a better understanding of the computer world.

    Further Reading

Viewing 1 post (of 1 total)