Skip to content

Instantly share code, notes, and snippets.

@LunaBorowska
Created August 31, 2012 14:01
Show Gist options
  • Save LunaBorowska/3553061 to your computer and use it in GitHub Desktop.
Save LunaBorowska/3553061 to your computer and use it in GitHub Desktop.

Build Status

python-format is implementation of Python's str.format(). It works both in browser and in Node.js. If you want to use this in Node.js, just type npm install python-format in console.

var format = require('python-format')
console.log(format('My nick is {0}.', 'GlitchMr'))

If you want to use this in browser, download python-format.js, if you want, pass it using your favorite JavaScript minifizer (I prefer UglifyJS, but you can use other minifizers).

For more details see http://docs.python.org/py3k/library/stdtypes.html#str.format.

Changelog

1.0.1

  • -0 is returned instead of -0 when dealing with format('{:g}', -0).

1.0.0

  • First release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment