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 | |
""" | |
cache_requests | |
-------------- | |
This module implements a basic LRU decorator that syncs calls with a redislite database. | |
ELI5: If you call the same function with the same parameters, it does not recalculate | |
the function. Instead, the first time, the results are stored, the second time the |
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
url = 'https://www.reddit.com/r/learnpython/comments' \ | |
'/2ztwnt/how_to_use_string_questions_on_quotes_str_i_have/' | |
alt = ('https://www.reddit.com/r/learnpython/comments' | |
'/2ztwnt/how_to_use_string_questions_on_quotes_str_i_have/') |
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
# coding=utf-8 | |
import collections | |
data = {'one': 1, 'two': 2, 'three': 3, 'a': 2} | |
sorted_data = collections.OrderedDict(sorted(data.items())) | |
print sorted_data | |
print sorted_data['three'] |
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
# coding=utf-8 | |
def is_valid(input_): | |
"""validation rules""" | |
return input_ in '012345ABC' | |
while True: | |
choice = raw_input() | |
if is_valid(choice): | |
break |
NewerOlder