Real Python Guide
repository·master·Indexed 12 days ago
https://github.com/realpython/python-guideEducational guides and scenarios for learning Python, featuring instructions on building command-line applications, configuring editors like Vim and Atom for PEP 8, and managing environments using pyenv, virtualenv, Pipenv, and virtualenvwrapper. Includes setup guides for interactive shells such as IPython, bpython, and ptpython.
What's inside Real Python Guide
- Python is a primary language for high-performance scientific computing due to its ease of use and integration with high-performance external libraries (written in C or Fortran). The ecosystem relies on a stack of specialized libraries for array manipulation, mathematical functions, plotting, and data analysis. For a deep dive into these tools, refer to the Python Scientific Lecture Notes.
Overview of Buildout
masterBuildout is an open-source software build tool written in Python. It follows the principle of separating configuration from the setup scripts. It is primarily used to download and set up dependencies in thePython eggsformat for software development or deployment. Users can create custom recipes for specific build tasks in various environments.Overview of C/C++ Interfacing Tools
masterWhen choosing a method to interface Python with C/C++, consider these primary tools:
- CFFI: Best for simple ABI compatibility (dynamic loading) or building C extension modules. Works with CPython and PyPy.
- ctypes: The standard library approach for CPython. Provides access to native OS APIs (like
kernel32on Windows orlibcon *nix) and allows manual definition of structs/unions. - SWIG: A tool-based approach that generates bindings from header files. Powerful for exposing large C++ codebases to Python, including the ability to extend classes via interface files.
- Boost.Python: A more manual but highly capable library for C++. It allows accessing
PyObjectsin C++, extracting SWIG wrappers, and embedding Python code within C++ applications.
Overview of Python GUI Frameworks
masterThis guide provides an alphabetical list of various Python libraries used for building Graphical User Interfaces (GUIs), ranging from native OS bindings to cross-platform toolkits.
Cross-Platform Toolkits
- Kivy: A library for multi-touch enabled, media-rich applications. It is based on OpenGL and supports Linux, OS X, Windows, and Android.
- PySide / PyQt: Python bindings for the Qt Framework. Note that PyQt may require a commercial license if your software is not GPL-compliant.
- PySimpleGUI: A wrapper for Tkinter and Qt designed for rapid development.
- Toga: A native, OS-native, cross-platform toolkit that provides a shared interface for macOS, Windows, Linux (GTK), Android, and iOS.
- wxPython: A wrapper for the wxWidgets C++ library.
- Tkinter: A thin object-oriented layer on top of Tcl/Tk. It is included in the Python standard library, making it the most convenient and compatible option.
Platform-Specific Frameworks
- Cocoa / PyObjC: Only available on OS X. Do not use these for cross-platform applications.
- PyGObject (PyGi): Provides Python bindings for the GNOME software platform and is fully compatible with GTK+ 3. (Note: PyGTK is deprecated and should be replaced by PyGObject).
Use Twisted for event-driven networking
masterTwisted is an event-driven networking engine used to build applications across various protocols. It is suitable for implementing HTTP servers and clients, as well as applications utilizing SMTP, POP3, IMAP, or SSH protocols, instant messaging, and more.Choose a Python library for creating Command-line Applications
masterWhen building a Command-line Application (or Console Application), you can choose from several Python libraries depending on your complexity requirements and preferred development style:
- Click: A highly configurable "Command-Line Interface Creation Kit" designed for composability with minimal code and sensible defaults.
- docopt: A lightweight, Pythonic approach that creates interfaces by parsing POSIX-style usage instructions.
- Plac: A simple, declarative wrapper over the standard library
argparse. It infers the argument parser from your code, making it ideal for quick scripts and sysadmins. - Cliff: A framework designed for building multi-level command structures (like
gitorsvn) usingsetuptoolsentry points for subcommands and output formatters. - Cement: An advanced, feature-full framework suitable for everything from micro-framework needs to complex, large-scale CLI applications.
- Python Fire: A library by Google that automatically generates a CLI from any Python object, useful for debugging, exploring code in a REPL, or transitioning between Python and Shell.
Use IDLE for small Python experiments
masterIDLE is an integrated development environment included in the Python standard distribution. It is written in Python using the Tkinter GUI toolkit. While not intended for full-scale application development, it is useful for testing small code snippets and experimenting with Python features.
Key features include:
- A Python Shell window (interpreter)
- A multi-window text editor with Python syntax colorization
- Minimal debugging capabilities
Freeze code using py2app (macOS)
masterpy2appis a specialized tool for creating macOS application bundles. It is primarily used for macOS and supports Python 3.Use gevent for coroutine-based networking
mastergevent is a coroutine-based networking library that utilizes greenlets to provide a high-level synchronous API built on top of the libev event loop.Understand the purpose of The Hitchhiker's Guide to Python
masterThe Hitchhiker's Guide to Python is a best practice handbook designed for both novice and expert Python developers. It provides guidance on the installation, configuration, and daily usage of the Python programming language.What is WSGI and why is it used?
masterThe Web Server Gateway Interface (WSGI) is a standardized interface between web servers and Python web application frameworks. It ensures portability by allowing Python web code to be deployed on any WSGI-compliant web server. WSGI is documented in PEP 3333.Overview of ZeroMQ for distributed systems
masterZeroMQ (also spelled ØMQ, 0MQ, or ZMQ) is a high-performance asynchronous messaging library designed for scalable distributed or concurrent applications. Unlike traditional message-oriented middleware, ZeroMQ can operate without a dedicated message broker. It provides a message queue using a familiar socket-style API.