Created
June 1, 2015 04:34
-
-
Save offby1/ff91f16aeeac05ceaa09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| class Template(string.Formatter): | |
| def format_field(self, value, spec): | |
| if spec.endswith('h'): | |
| value = str(value) # ultimately, this will call a funtion that will format the value and return as string | |
| spec = spec[:-1] + 's' | |
| return super(Template, self).format_field(value, spec) | |
| f= Template() | |
| print(f.format("Hello {:h}", "world")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment