Articles & notes
We write about development, artificial intelligence and what inspires us. Sharing the experience of the Pandora Research team.
Connecting S3 storage to a Django project
A step-by-step guide to serving static and media files through an S3-compatible Yandex.Cloud bucket in Django using django-storages and boto3.
AsyncIO in Python
We break down the architecture of the asyncio event loop, its main elements, and write a simple asynchronous Python program, accounting for the changes in version 3.11.
A Dockerfile for a Django project
A worked example of writing a Dockerfile for a Django project: choosing a base image, installing dependencies, serving static files with nginx and a startup script with gunicorn.
The GIL: Python's Global Interpreter Lock
We explain what the GIL (Global Interpreter Lock) is, how reference counting in Python relates to the global lock, and when threads still make sense.
Git: version-control basics
A concise cheat sheet for the core Git commands: initializing and configuring a repository, working with the index, commits and rolling back changes — with example commands and output.
Context managers and the with statement
A look at why context managers and the with statement exist in Python and how to build your own — both class-based with __enter__/__exit__ methods and generator-based with the contextmanager decorator.
Generators in Python
We explore what generators are in Python, how the yield keyword works, how a generator differs from an iterator, and where generators are useful — from infinite sequences to reading large files.
Decorators in Python
A guide to decorators in Python: higher-order functions and closures as their foundation, the @ syntactic sugar, passing arguments via *args and **kwargs, and a universal decorator template.
Iterators in Python
A hands-on look at how iterators work in Python: we build a range clone with __iter__ and __next__, see how the for loop works under the hood, and meet the built-in enumerate, zip and open iterators.
Coroutines in Python
A look at coroutines in Python: how they build on generators, the yield expression and the send method, a decorator for priming them, and the advantages and drawbacks of the asynchronous approach.