This file contains hidden or 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
letters = ['a', 'b', 'c'] | |
numbers = [1, 2, 3] | |
squares = [1, 4, 9] | |
zipped_list = zip(letters, numbers, squares) | |
# zipped_list = [('a', 1, 1), ('b', 2, 4), ('c', 3, 9)] |
This file contains hidden or 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
start_list = [1,2,3,3,4,1] | |
set(start_list) | |
# возвращает set([1,2,3,4]) | |
if len(start_list) == len(set(start_list)): | |
print 'List is unique!' |
This file contains hidden or 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
# start_dict = {'Dick': '[email protected]', 'Jane': '[email protected]', 'Stou': '[email protected]'} | |
result_dict = dict( [name, '.com' in email] for name, email in start_dict.iteritems() ) | |
# result_dict = {'Dick': True, 'Jane': True, 'Stou': False} |
This file contains hidden or 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
keycode = 2 | |
functions = {1: func1, 2: func2, 3: func3} | |
functions.get(keycode, default_func)() |
This file contains hidden or 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
def reverseString(aStr): | |
# base case: | |
if len(aStr) == 0: | |
return '' | |
# recursive case: | |
else: | |
return aStr[-1:] + reverseString(aStr[:-1]) |
This file contains hidden or 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 bash | |
# file: ~/.virtualenvs/postmkvirtualenv | |
# This hook is run after a new virtualenv is activated. | |
# setup python interpretor and sitepackages | |
# for Sublime Text's SublimeCodeIntel plugin. | |
# codeintel looks in the root of any folder opened via `subl foldername` | |
# for foldername/.codeintel/config | |
# it also looks in ~/.codeintel/config |
This file contains hidden or 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 SplitTextMultiWidget(forms.MultiWidget): | |
def __init__(self, attrs=None): | |
_widgets = ( | |
forms.TextInput(attrs={'class': 'input-second'}), | |
forms.TextInput(attrs={'class': 'input-second'}), | |
) | |
super(SplitTextMultiWidget, self).__init__(_widgets, attrs) | |
def decompress(self, values): |
This file contains hidden or 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
# forms.py ==================================================================== | |
from django import forms | |
class NAMEForm(forms.Form): | |
FIELDNAME1 = forms.CharField(required=True,) | |
FIELDNAME2 = forms.CharField( | |
widget=forms.Textarea(attrs={'class': 'input-second'}),) | |
# views.py ==================================================================== | |
from project.apps.APPNAME.forms import NAMEForm | |
from django.http import HttpResponseRedirect |
This file contains hidden or 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
DebuggingServer |
This file contains hidden or 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
*.py~ | |
*.py[cod] | |
local_settings.py | |
*.db | |
*sublime* | |
wsgi.py |