Book Image

Kivy Blueprints

Book Image

Kivy Blueprints

Overview of this book

Table of Contents (17 chapters)
Kivy Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Python Ecosystem
Index

Appendix A. The Python Ecosystem

This book doesn't attempt to answer all the questions that you might have had about Kivy, or exemplify every remotely possible approach to writing a Kivy app; it should instead serve as a practical, hands-on introduction to writing various programs with a user interface in Python.

Kivy's major achievement is bridging the gap between a Python toolchain and mobile app development on Android and iOS. Unlike bindings to Qt (PyQt and PySide), Kivy is inherently Pythonic (apart from minor implementation details such as the Window object). These two aspects alone make Kivy a viable option to consider when writing your next user-facing application.

This notwithstanding, I strongly encourage you to explore the vast Python ecosystem. It just so happens that a great many Python modules manage to stay under the radar. Kivy is actually one of them, overshadowed by, for example, the relatively more popular Qt framework (they clearly don't belong in the same ballpark, but a common misconception is that these are mostly interchangeable, for reasons unclear).

The following annotated list contains a few interesting Python modules, both well-known and relatively obscure. This may serve as an inspiration for writing a new app, or merely as an illustration of the riches found in the Python biome. Obviously, this list is far from complete, or even extensive: you will certainly uncover many other unique libraries and tools over the course of your Python career.

So here it is, a highly subjective enumeration of selected, downright amazing Python packages, in no particular order:

  • Requests: This module is a well-known, über-useful HTTP package with readable, consistent interface. It greatly simplifies writing all sorts of HTTP clients.

  • Pyjnius: Discussed in slightly more detail in Chapter 3, Sound Recorder for Android, this module provides a seamless and relatively lightweight Java interoperability layer. This tool lets you reuse any Java library, on Android and desktop, from the comfort of your Python environment. Needless to say, Java libraries (of equivocal usefulness) come in great numbers, so Pyjnius may prove useful on many occasions.

  • mitmproxy (man-in-the-middle proxy): This is a toolkit for capturing and editing HTTP traffic. Possible uses for mitmproxy include debugging and testing network applications, security auditing, and otherwise toying with unsuspecting programs. It can be also exploited as a network screen for filtering traffic; this particular use case is popular with governments these days. Might land you a job with the KGB, or not.

  • music21: This is a toolkit for computer-aided musicology developed at MIT that provides a way to work with symbolic music data. It allows you to read, write, and manipulate musical scores, conduct complex musical and statistical analysis on a representative corpus of classical music, fiddle with algorithmic composition, and so on.

  • Pydub: This is a library for audio manipulation with a consistent, Pythonic interface. It allows you to perform a number of audio editing tasks, such as slicing, concatenating, crossfading, and so on. Pydub uses ffmpeg for transcoding, which means it supports most popular file formats out of the box.

  • Django: This is an undoubtedly popular web framework for building dynamic, database-backed websites. What many people don't suspect, however, is that Django can also be used for many other, barely related, tasks that include the following:

    • Making powerful command-line tools for database manipulation, using Django models and object-relational mapping (ORM)

    • Employing the excellent Django's template engine for pretty much anything that requires a template engine

    • Building static websites

  • RenPy (stylized as Ren'Py): This is a visual novel engine, used for professional game development. Visual novels, once practically unheard of outside Japan, are becoming more popular now, with selected RenPy-powered titles readily available for consumption on the AppStore, Google Play, Steam, and via other software distribution channels.

NumPy, SciPy, IPython, and so on were purposefully omitted from the preceding list; they are so pervasive that there is hardly any need to reintroduce them.

Note

If you find this topic mildly interesting and would like to learn more, there are a few websites that might be useful:

  • Awesome Python, a curated list of awesome Python software is available at https://github.com/vinta/awesome-python#awesome-python

  • The Hitchhiker's Guide to Python is an opinionated handbook of Python best practices, covering many interrelated topics. It is located at http://docs.python-guide.org/en/latest/#scenario-guide

  • PyMOTW, the Python Module of the Week series by Doug Hellmann, can be found at http://pymotw.com/2/contents.html

  • Last but not least, the official Python wiki hosts a directory of useful packages at https://wiki.python.org/moin/UsefulModules

The multitude of packages that provide practical solutions to real-world problems is a defining characteristic of today's Python programming. Code reuse is great, so in no event should you hesitate to borrow from the rich Python ecosystem and to give back when (if) that's feasible.

As a direct consequence of the preceding discussion, Python expands your toolbelt with many things that are universally considered non-trivial. This includes a certain subset of scientific computations, secure and scalable web servers, network services, fast hardware-accelerated graphics, and so on.

This is a valid reason to choose Python for your next project, and it also gives some insight into why many great projects loaded with powerful features—such as Kivy—are written in Python (and related languages, for example, RPython).

The moral of the story: know your ecosystem and it will pay off immensely by shouldering a lot of hard work, making you more productive and your hair soft and silky. Because having a right tool for the job is indispensable.