- @Kracekumar
- Have used both Flask and Django.
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
class Foo(object): | |
lang = 'python' | |
def __getattr__(self, attr): | |
return 'No' | |
>>>Foo.lang | |
'python' | |
>>>Foo.os |
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
import sys | |
try: | |
from inlinestyler.utils import inline_css | |
except ImportError: | |
sys.stderr.write("inlinestyler is missing. `pip install inlinestyler == 0.2.0`") | |
if __name__ == "__main__": | |
if len(sys.argv) != 3: |
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
In [4]: class Foo(object): | |
...: def __init__(self, func=None): | |
...: if func: | |
...: # Better validation is required | |
...: self.execute = types.MethodType(func, self) | |
...: def execute(self): | |
...: print "Normal" | |
...: | |
In [5]: def execute(self): |
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
tagging.clj:15 jok.tagging/track-metadata | |
yellow.clj:7 jok.models.yellow/to-song | |
core.clj:2434 clojure.core/map[fn] | |
LazySeq.java:42 clojure.lang.LazySeq.sval | |
LazySeq.java:60 clojure.lang.LazySeq.seq | |
RT.java:473 clojure.lang.RT.seq | |
core.clj:133 clojure.core/seq | |
core.clj:2426 clojure.core/map[fn] | |
LazySeq.java:42 clojure.lang.LazySeq.sval | |
LazySeq.java:60 clojure.lang.LazySeq.seq |
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 -*- | |
class ConsoleExceptionLoggerMiddleware(object): | |
def process_exception(self, request, exception): | |
import traceback | |
import sys | |
exc_info = sys.exc_info() | |
print("-" * 30 + "Exception" + "-" * 50) | |
print('\n'.join(traceback.format_exception(*(exc_info or sys.exc_info())))) |
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
MIDDLEWARE_CLASSES = ( | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
'metadata.exception_logger.ConsoleExceptionLoggerMiddleware', |
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
bench)➜ bench ./manage.py runserver | |
Performing system checks... | |
System check identified no issues (0 silenced). | |
March 08, 2015 - 10:42:45 | |
Django version 1.7.5, using settings 'bench.settings' | |
Starting development server at http://127.0.0.1:8000/ | |
Quit the server with CONTROL-C. | |
######################## Exception ############################# | |
Traceback (most recent call last): |
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
In [1]: class Test: | |
...: def __init__(self): | |
...: self.a = 1 | |
...: | |
In [2]: t = Test() | |
In [3]: getattr(object=t, name='a') | |
--------------------------------------------------------------------------- |