Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Accessing a dynamic library using ctypes

In this section, we're going to narrow down our focus to the Python standard library's ctypes package, which allows us to interact with dynamic libraries from within Python.

Locating and linking a dynamic library

Probably, the most common need to interact with compiled code is when there's a library out there that does exactly what we need but it's not a Python library. Perhaps it was instead written for C, or it has a C interface.

We're not going to let a little thing like this stop us. Instead, we'll use ctypes to create an interface module for the library. For basic usage, ctypes is very simple. We just need to import it, load the dynamic library by...