Created
November 6, 2013 01:36
-
-
Save whardier/7329478 to your computer and use it in GitHub Desktop.
I feel somewhat evil about this.. however it's been incredibly useful
This file contains 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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
def format_vars(format_string, format_vars=None): | |
if not format_vars: | |
format_vars = globals() | |
return format_string.format(**format_vars) | |
if __name__ == "__main__": | |
supdog = 'yo howdy' | |
print format_vars("{__name__} says {supdog}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ignore the part where I override the function name within the function.. that's not for you to care about.