Boto3 comes with the Stubber class, but it doesn’t work well for all calls. In those cases
Posts for: #Python
Organizing Python Packages and User-Facing API with init
Python gives you a number of options for exporting the public portions of your package’s API depending on the needs of your users. These are exposed via init.py. This allows…
Pickled Object Versioning and Compatibility
When you have a class that is used to hold data and is regularly pickled and later retrieved and unpickled, updates to the class in the environment that unpickle the object can…
Overriding Class Methods in Python
In order to override a class method, the overriding method should also be decorated as a class method and take a required parameter cls, from which you can get class…
Installing Dependencies from Github Repos with Pip and Poetry
There is a standardized way to install Python packages from VCS repos. The examples will show a complex case that include a branch and subdirectory
Dispatch Tables in Python
Dispatch tables are a useful way to use a string to determine which function to call. Why would you do this? When designing an interface to be used in other people’s code, you…
Passing Arguments from Main Commands to Subcommands in Click
If you have command groups in your CLI application so that you have subcommands, you can pass arguments from the group down to the subcommands with the context object. Here’s…
Type hint for any subclass in Python
To use a type hint to specify a parameter can be any subclass object of the hinted class, use typing.Type and in the annotation do Type[A]. This is useful if getting warnings…
Installing Scipy with Docker
Certain packages can be troublesome to install in a Docker container when they’re defined in a requirements.txt file, such as scipy. If you’re running into issues installing…
Click Quickstart and Reference
What it looks like: shell $ python hello.py –help Usage: hello.py [OPTIONS] NAME