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 __call__(self, *args, **kwargs): | |
"""Overriding the __call__ function which makes the | |
instance callable. | |
""" | |
# fetching the function to be invoked from the virtual namespace | |
# through the arguments. | |
fn = Namespace.get_instance().get(self.fn, *args) | |
if not fn: |
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
@overload | |
def area(l, b): | |
return l * b | |
@overload | |
def area(r): | |
import math | |
return math.pi * r ** 2 |
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
Python 2.7.10 (default, Feb 22 2019, 21:55:15) | |
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> |
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 foo(a, b): | |
... return a + b | |
... | |
>>> |
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 sys | |
>>> sys.ps1 = '::: ' | |
::: |
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 sys | |
sys.ps1 = "\033[1;33m>>>\033[0m " | |
sys.ps2 = "\033[1;34m...\033[0m " |
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
# -*- coding: utf-8 -*- | |
import sys | |
class IPythonPromptPS1(object): | |
def __init__(self): | |
self.line = 0 | |
def __str__(self): | |
self.line += 1 | |
return "\033[92mIn [%d]:\033[0m " % (self.line) | |
sys.ps1 = IPythonPromptPS1() | |
sys.ps2 = " \033[91m...\033[0m " |
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
export PYTHONSTARTUP="$HOME/ipython.py" |
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 get_ratelimit_config(key): | |
value = cache.get(key) | |
if not value: | |
value = config_store.get(key) | |
cache.put(key, value) | |
return value |
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 get_current_window(key, start_time): | |
ts_data = requests_store.get(key) | |
if not key: | |
return 0 | |
total_requests = 0 | |
for ts, count in ts_data.items(): | |
if ts > start_time: | |
total_requests += count | |
else: |