Skip to content

Instantly share code, notes, and snippets.

@whardier
Created November 6, 2013 01:36
Show Gist options
  • Save whardier/7329478 to your computer and use it in GitHub Desktop.
Save whardier/7329478 to your computer and use it in GitHub Desktop.
I feel somewhat evil about this.. however it's been incredibly useful
#!/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}")
@whardier
Copy link
Author

whardier commented Nov 6, 2013

Ignore the part where I override the function name within the function.. that's not for you to care about.

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