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
l=[3,11,4,3,4,62,6,67,8,3,2246] | |
tmp = l[0] | |
for i in range(len(l)): | |
if l[i]<tmp: | |
tmp = l[i] | |
print tmp |
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 Stack: | |
def __init__(self): | |
self.items = [] | |
def isEmpty(self): | |
return self.items == [] | |
def push(self, item): | |
self.items.append(item) |
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 parChecker(symbolString): | |
s = Stack() | |
balanced = True | |
index = 0 | |
while index < len(symbolString) and balanced: | |
symbol = symbolString[index] | |
if symbol in "([{": | |
s.push(symbol) | |
else: | |
if s.isEmpty(): |
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 divideBy2(decNumber): | |
remstack = Stack() | |
while decNumber > 0: | |
rem = decNumber % 2 | |
remstack.push(rem) | |
decNumber = decNumber // 2 | |
binString = "" | |
while not remstack.isEmpty(): |
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 baseConverter(decNumber,base): | |
digits = "0123456789ABCDEF" | |
remstack = Stack() | |
while decNumber > 0: | |
rem = decNumber % base | |
remstack.push(rem) | |
decNumber = decNumber // base |
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 reverse(s): | |
if len(s)<=1: | |
return s | |
else: | |
return reverse(s[1:]) + s[0] |
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
import os | |
# here() gives us file paths from the root of the system to the directory | |
# holding the current file. | |
here = lambda * x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x) | |
PROJECT_ROOT = here("..") | |
# root() gives us file paths from the root of the system to whatever | |
# folder(s) we pass it starting at the parent directory of the current file. | |
root = lambda * x: os.path.join(os.path.abspath(PROJECT_ROOT), *x) |
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
""" | |
reloadall.py: транзитивная перезагрузка вложенных модулей | |
""" | |
import types | |
from imp import reload | |
# требуется в версии 3.0 | |
def status(module): | |
print('reloading' + module.__name__) |
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
#-*- coding: utf-8 -*- | |
class AttrDisplay: | |
""" | |
Реализует наследуемый метод перегрузки операции вывода, отображающий | |
имена классов экземпляров и все атрибуты в виде пар имя=значение, | |
имеющиеся в экземплярах (исключая атрибуты, унаследованные от классов). | |
Может добавляться в любые классы и способен работать с любыми | |
экземплярами. | |
""" | |
def gatherAttrs(self): |
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 LoginRequiredMixin(object): | |
@method_decorator(login_required) | |
def dispatch(self, request, *args, **kwargs): | |
return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs) |