Skip to main content

Reusable f-strings

Project description

F-yeah!

Reusable f-strings

Shed all outdated format sytles from your code. With F-yeah Just add parentheses and be on your way.

Usage

No more copying around f-strings

Keep your templates DRY without reverting to older format styles.

def action1(value):
    assert isinstance(value, int), 'Expected value to be an integer, got {type(value)} instead'
    return value * value

def action2(value):
    assert isinstance(value, int), 'Expected value to be an integer, got {type(value)} instead'
    return value ** value

Just write the template once to get consistent strings that stay in sync.

from fyeah import f
bad_check = 'Expected value to be an integer, got {type(value)} instead'

def action1(value):
    assert isinstance(value, int), f(bad_check)
    return value * value

def action2(value):
    assert isinstance(value, int), f(bad_check)
    return value ** value

No more format calls, ever!

Consolidate on f-string style format for all templates, local or global.

bad_check = 'expected value to be an integer, got {type(value)} instead'

def action1(value):
    assert isinstance(value, int), bad_check.format(value=value)
    return value * value

def action2(value):
    assert isinstance(value, int), bad_check.format(value=value)
    return value ** value

Just use the same format string as a reusable f-string instead.

from fyeah import f
bad_check = 'Expected value to be an integer, got {type(value)} instead'

def action1(value):
    assert isinstance(value, int), f(bad_check)
    return value * value

def action2(value):
    assert isinstance(value, int), f(bad_check)
    return value ** value

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-yeah-0.1.5.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distributions

f_yeah-0.1.5-cp38-cp38-manylinux1_x86_64.whl (135.7 kB view hashes)

Uploaded CPython 3.8

f_yeah-0.1.5-cp38-cp38-macosx_10_14_x86_64.whl (38.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

f_yeah-0.1.5-cp37-cp37m-manylinux1_x86_64.whl (128.0 kB view hashes)

Uploaded CPython 3.7m

f_yeah-0.1.5-cp37-cp37m-macosx_10_14_x86_64.whl (33.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

f_yeah-0.1.5-cp36-cp36m-manylinux1_x86_64.whl (126.7 kB view hashes)

Uploaded CPython 3.6m

f_yeah-0.1.5-cp36-cp36m-macosx_10_14_x86_64.whl (33.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

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