Skip to content

Instantly share code, notes, and snippets.

View iamkhush's full-sized avatar

Ankush Chadda iamkhush

View GitHub Profile
@ashwch
ashwch / show.md
Created July 23, 2017 23:29
Show

This is possible when you import a module in shell and then make changes to the file but you are still using the same old module in shell. The solution is to reload the module or re-start the shell. This happens because the shell we try to load the latest code based up the error stack and display it to you.

# so.py
def func():
    print(foo.bar)

Start of shell session

>>> import so
@kesor
kesor / profile_middleware.py
Last active March 16, 2021 15:37
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG: