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 timeit | |
t = timeit.Timer("v=sorted(d.items(), key=lambda x: x[1])[-1]", | |
"d = {'a': 1000, 'b': 3000, 'c':100}") | |
print t.timeit() | |
# 1.648s | |
t = timeit.Timer("v=max(d.iteritems(), key = operator.itemgetter(1))[0]", | |
"import operator; d = {'a': 1000, 'b': 3000, 'c':100}") | |
print t.timeit() |
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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import urllib | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
import pickle | |
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
function auto_activate { | |
SEARCHPATH=`pwd` | |
function activate_env { | |
# ZSH outputs errors for the ls * command if you don't disable the nomatch output | |
unsetopt nomatch 2>/dev/null | |
ls $SEARCHPATH/*/bin/activate > /dev/null 2> /dev/null | |
if [ "$?" = '0' ]; then | |
deactivate > /dev/null 2> /dev/null |
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
.... | |
from django.views.generic import ListView | |
from sgf.utils.decorators import page, permission_required_sgf | |
from sgf.administrativo.models import ComiteRegional | |
from sgf.administrativo.forms import FormComiteRegionalBusca | |
...... | |
class SearchListView(ListView): |
NewerOlder