Skip to main content

Python Bindings for Confetti

This repository contains Python bindings for Confetti. For a pure Python implementation of Confetti, see PyConfetti.

The bindings correspond one-to-one with the Confetti C API whereas the pure Python implementation offers a higher-level interface that deserializes Confetti directly into Python data structures. The latter is recommended for most use cases.

Build Status

Installation

Install the bindings with

$ pip install cconfetti

The bindings require you to have a C compiler accessible to Python.

Complete Example

The following complete Python program reads Confetti source text from standard input and pretty prints it to standard output.

import cconfetti

def print_indent(depth) -> None:
    for i in range(depth):
        print("    ", end="")

def print_directives(directive, depth) -> None:
    print_indent(depth)

    # The directive arguments.
    for index,arg in enumerate(directive.arguments):
        print(arg.value, end=" ")

    # The directive's subdirectives.
    if len(directive.subdirectives) > 0:
        print("{")
        for subdir in directive.subdirectives:
            print_directives(subdir, depth + 1)
        print_indent(depth)
        print("}")
    else:
        print("")

source = input("Enter Confetti: ")
directives = cconfetti.parse(source)
for dir in directives:
    print_directives(dir, 0)

License

MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cconfetti-0.1.0.tar.gz (37.8 kB view details)

Uploaded Source

File details

Details for the file cconfetti-0.1.0.tar.gz.

File metadata

  • Download URL: cconfetti-0.1.0.tar.gz
  • Upload date:
  • Size: 37.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for cconfetti-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12ddd9fbfd5a771361ea88673f2c4e5a66b2bfd7d37a35644722522c653e0a15
MD5 23203c9cb099bc479058cf25647840b3
BLAKE2b-256 52808c85a8526716b7f20bbf41954bf75760d677595d59f713e7da460e31a9fd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page