Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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


Release history Release notifications

Download files

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

Files for f-yeah, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size f_yeah-0.1.0-py3-none-any.whl (3.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size f-yeah-0.1.0.tar.gz (1.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page