Take a look at radare2. It can parse file formats (see here for an example of parsing the ELF header).

Radare2 supports multiple architectures and is being actively developed. On top of that it has bindings for a lot of languages, including Python of course. Read through the bindings source code to see it is pretty straightforward to script it.

HTH!

Answer from Carlos Garcia on Stack Exchange
🌐
GitHub
github.com › eliben › pyelftools
GitHub - eliben/pyelftools: Parsing ELF and DWARF in Python · GitHub
pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information.
Starred by 2.3K users
Forked by 543 users
Languages   Python 97.7% | C 1.5% | Assembly 0.5% | Linker Script 0.1% | Makefile 0.1% | Nix 0.1%
🌐
Medium
medium.com › analytics-vidhya › exploring-elf-files-using-pyelftools-93bb7665cce3
Exploring ELF files using pyelftools | by Roman Storozhenko | Analytics Vidhya | Medium
October 27, 2020 - hedin@home:~/projects/elf$ lsb_release -a LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal hedin@home:~/projects/elf$ python3 --version Python 3.8.5
🌐
PyPI
pypi.org › project › elf
elf: Advent of Code helper for Python
A fast, modern Advent of Code CLI with caching, guardrails, leaderboards, and a lightweight Python API.
      » pip install elf
    
Published   Dec 04, 2025
Version   1.1.1
🌐
PyPI
pypi.org › project › elffile
elffile · PyPI
Elffile is a pure python implementation of a library which reads and writes ELF format object files
      » pip install elffile
    
Published   Feb 07, 2011
Version   0.005
🌐
Lief
lief.re › doc › latest › formats › elf › python.html
Python — LIEF Documentation - ELF
2 weeks ago - lief.ELF.parse(obj: str | io.IOBase | os.PathLike | bytes | list[int], config: lief.ELF.ParserConfig) → lief.ELF.Binary | None¶
🌐
GitHub
github.com › tbursztyka › python-elf
GitHub - tbursztyka/python-elf: An ELF format manipulation library in python
Python-ELF ========== Python-ELF is a python library targeting ELF binary format manipulation. It is OS and machine independant, or tends to be. It has nothing new nor nothing better than existing libraries and currently is suffers from lacks ...
Starred by 18 users
Forked by 7 users
Languages   Python 100.0% | Python 100.0%
🌐
Eli Bendersky
eli.thegreenplace.net › 2012 › 01 › 06 › pyelftools-python-library-for-parsing-elf-and-dwarf
pyelftools - Python library for parsing ELF and DWARF - Eli Bendersky's website
January 6, 2012 - I'm happy and proud to announce the release of a new open-source Python package to the world. pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information. It provides both low-level and high-level APIs for querying ELF and DWARF, and is mostly ...
🌐
PyPI
pypi.org › project › pyelftools
pyelftools · PyPI
Library for analyzing ELF files and DWARF debugging information
      » pip install pyelftools
    
Published   May 29, 2026
Version   0.33
Find elsewhere
🌐
Anaconda.org
anaconda.org › conda-forge › python-elf
python-elf - conda-forge | Anaconda.org
Install python-elf with Anaconda.org. Utils and convenience functions for large-scale bio-image analysis.
🌐
DEV Community
dev.to › icyphox › python-for-reverse-engineering-1-elf-binaries-1fo4
Python for Reverse Engineering #1: ELF Binaries - DEV Community
March 14, 2019 - As the title suggests, you’re going to need a Python 3 interpreter before anything else. Once you’ve confirmed beyond reasonable doubt that you do, in fact, have a Python 3 interpreter installed on your system, run ... where capstone is the disassembly engine we’ll be scripting with and pyelftools to help parse ELF files.
🌐
pwntools
docs.pwntools.com › en › stable › elf › elf.html
pwnlib.elf.elf — ELF Files — pwntools 4.15.0 documentation
Takes a path to a file on the local filesystem, and returns an ELFFile from it, setting up a correct stream_loader relative to the original file.
🌐
GitHub
github.com › v3l0c1r4pt0r › makeelf
GitHub - v3l0c1r4pt0r/makeelf: ELF reader-writer library for Python3 · GitHub
MakeELF is a Python library to parse, modify and create ELF binaries.
Starred by 67 users
Forked by 29 users
Languages   Python
🌐
pytz
pythonhosted.org › elffile
Welcome to elffile’s documentation! — elffile v0.003 documentation
Elffile is a library which reads and writes ELF format object files.
🌐
Linux Security Expert
linuxsecurity.expert › linux security expert › tools › pyelftools
Pyelftools review (ELF parsing toolkit) - Linux Security Expert
September 10, 2024 - Pyelftools is a Python library to parse ELF files and DWARF debugging information. It can be useful to perform dynamic binary analysis on files.
🌐
GitHub
github.com › constantinpape › elf
GitHub - constantinpape/elf: Utility functions for large-scale bio-image analysis. · GitHub
pip install python-elf · or from conda: conda install -c conda-forge python-elf · Segmentation: elf implements graph-based segmentation using the implementations of multict, lifted multicut and other graph partitioning approaches from nifty. Check out the examples to see how to use this functionality for segmenting your data.
Starred by 64 users
Forked by 23 users
Languages   Python 93.6% | Jupyter Notebook 6.4%