GitXplorerGitXplorer
M

fstrings

public
11 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
63908822117f8f5960111ba45896d62b0da8bfda

Update README

MMortal committed 8 years ago
Unverified
abf50a862777d48592260f9ef544e16753ab654d

Make fstrings.vim more portable

MMortal committed 8 years ago
Unverified
74dc763ca5574e4979e882cdd069e3b3b561b351

Support multidimensional slice syntax

MMortal committed 8 years ago
Unverified
d5fc0184d8da1282c764150e47e7d733069af55f

Support %d, %e, %f, %g

MMortal committed 8 years ago
Unverified
9c3c8cbc0705de85698daa927f2829555e33f392

Add break and continue

MMortal committed 8 years ago
Unverified
3f35ef98c7885e7b0c56fbc046c36df541ed6d53

Add more operators

MMortal committed 8 years ago

README

The README file for this repository.

Translate string formatting into string interpolation

Python 3.6 introduces F-strings as a new way of doing string formatting.

Instead of writing this:

def say(greeting='hello', target='world'):
    print('%s, %s!' % (greeting.title(), target))

... you can now write this:

def say(greeting='hello', target='world'):
    print(f'{greeting.title()}, {target}!')

This project provides automatic translation of old %-style formatting to the new string interpolation method using F-strings.

Editor integration

If you use Vim, then simply source the fstrings.vim file. Select a set of lines (with V) and press = to update the selection.

If you use another editor, you can invoke the fstrings.py script as follows:

python3.6 fstrings.py 40 50 < input.py > tmp.py

This parses all of input.py and outputs just lines 40-50 to tmp.py.