Skip to content

Instantly share code, notes, and snippets.

View santoshpy's full-sized avatar
🐍
Focusing

Santosh Purbey santoshpy

🐍
Focusing
View GitHub Profile
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@santoshpy
santoshpy / .dockerignore
Created January 16, 2021 18:58 — forked from jefftriplett/.dockerignore
How I use Docker and Compose
.*
!.coveragerc
!.env
!.pylintrc
@santoshpy
santoshpy / inspect_mate.py
Created December 26, 2018 09:40 — forked from MacHu-GWU/inspect_mate.py
``inspect_mate`` provides more methods to get information about class attribute than the standard library ``inspect``.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
``inspect_mate`` provides more methods to get information about class attribute
than the standard library ``inspect``.
This module is Python2/3 compatible, tested under Py2.7, 3.3, 3.4, 3.5, 3.6.
Includes tester function to check:
@santoshpy
santoshpy / beautiful_idiomatic_python.md
Last active August 16, 2018 15:37 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@santoshpy
santoshpy / 0_urllib2.py
Created November 25, 2016 14:23 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()