Skip to main content

Python 'f' Codec

Project description

Python f Codec

Wrap lonesome f-strings in print().

How to install

> python3 -m pip install f-codec

Why?

# -*- coding: f -*-

def dictionary(inst, depth=0):
    ಠ_ಠ = '    ' * depth

    f''' {{
'''

    for name, val in inst.items():
        if isinstance(val, dict):
            f'''
    {name} =
''' > ಠ_ಠ
            dictionary(val, depth + 1)
        else:
            f'''
    {name} = {val},
''' > ಠ_ಠ

    f'''
}}
''' > ಠ_ಠ

decl = {
    'a': 1,
    'b': 2,
    'c': { 'a': 3, 'b': 4 },
    'd': { 'a': 5, 'b': { 'a': 6, 'b': 7 }, 'c': 8 },
    'e': 9
}

f'''
decl =
'''
dictionary(decl)
> python3 test.py

decl = {
    a = 1,
    b = 2,
    c = {
        a = 3,
        b = 4,
    }
    d = {
        a = 5,
        b = {
            a = 6,
            b = 7,
        }
        c = 8,
    }
    e = 9,
}

Project details


Download files

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

Source Distribution

f-codec-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file f-codec-0.1.1.tar.gz.

File metadata

  • Download URL: f-codec-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for f-codec-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a059d3c4173b77121e8229b7ff4a4686f2c8c7240fb7aa1d0ebac47cb1ff069
MD5 07e6a01728d6921855b3894601ac2194
BLAKE2b-256 77a24a7a9d1e08f50c1566182865fd07c6cae96f75def5ce87c90b7ca7c012c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page