Skip to content

Instantly share code, notes, and snippets.

from django.http import HttpResponseRedirect
def has_perm_or_redirect(permission, redirect):
def wrapper(function):
def wrapped_function(request, *args, **kwargs):
if request.user.has_perm("tpd4.NONE"):
print request.user.has_perm("blah")
return function(request, *args, **kwargs)
else:
return HttpResponseRedirect(redirect)
import pickle
data1 = {'a': [1, 2.0, 3, 4+6j],
'b': ('string', u'Unicode string'),
'c': None}
selfref_list = [1, 2, 3]
selfref_list.append(selfref_list)
output = open('data.pkl', 'wb')
#!/usr/bin/python
# led.py - Sample classes and methods to get you started with LED's the OOP way.
def send_val_to_pin(pin, colorval):
print "Pin: %s | ColorVal: %s" % (str(pin), str(colorval))
class LED:
def __init__(self, pin_r, pin_g, pin_b):
self.pin_r = pin_r
self.pin_g = pin_g