-
-
Save kennethreitz/90c79b1c98d850eed711 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
def dictify(s): | |
items = s.split() | |
for i, item in enumerate(items): | |
if ':' in item: | |
items[i] = item.split(':') | |
else: | |
items[i] = (item, True) | |
print dict(items) | |
s = 'foo bar:baz' | |
print dictify(s) |
Author
kennethreitz
commented
Feb 12, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment