Bash Style Brace Expander

2.6 · active · verified Sun Mar 29

Bracex is a Python library that provides Bash-style brace expansion, enabling the generation of arbitrary strings from patterns. It closely emulates Bash's brace processing, supporting comma-separated lists, numerical and alphabetical sequences (ranges), and optional step increments. The library is actively maintained, with version 2.6 being the latest, and releases occur regularly to ensure compatibility with newer Python versions and address minor fixes.

Warnings

Install

Imports

Quickstart

Demonstrates basic brace expansion for lists, nested patterns, numerical and alphabetical sequences, and the generator-based iteration using `iexpand`.

import bracex

# Basic list expansion
print(bracex.expand(r'file-{a,b,c}.txt'))

# Nested brace expansion
print(bracex.expand(r'path/to/{{foo,bar},baz}/file.txt'))

# Numerical sequence (range) expansion
print(bracex.expand(r'image{00..02}.png'))

# Numerical sequence with step
print(bracex.expand(r'item{1..10..3}.log'))

# Alphabetic sequence
print(bracex.expand(r'letter{A..D}.md'))

# Using the generator version
for item in bracex.iexpand(r'data-{1..5}.csv'):
    print(item)

view raw JSON →