<code lang="python">...</code>
return "/blog/%i/" % self.id
заменить на return reverse('your_super_puper_view', kwargs={'pk': self.pk})
. Соответственно, почитать об этом в документацииclass A(object):
def __ge__(self, other):
return True
def __le__(self, other):
return True
print(continue_link.encode().decode('utf-8', 'ignore'))
class Retry(object):
"""
Retries function with exponential delay if it's releasing exception.
"""
def __init__(self, tries, exceptions=None, delay=1, exponent=1.5):
self.tries = tries
if exceptions:
self.exceptions = tuple(exceptions)
else:
self.exceptions = (Exception,)
self.delay = delay
self.exponent = exponent
def __call__(self, f):
def fn(*args, **kwargs):
exception = None
for i in range(self.tries):
try:
return f(*args, **kwargs)
except self.exceptions as e:
delay = self.delay * self.exponent ** i
if i + 1 == self.tries:
raise exception
sleep(delay)
exception = e
raise exception
return fn
@Retry(3)
def f():
...
docs = [[] for i in range(1)]
document = []
for line in open(mypath + '\\' + files[0]).readlines():
for word in line.split():
w = preprocessing(word, stop_words_list)
if w:
document.append(w)
from datetime import datetime
datetime.utcnow()
s = requests.Session()
r = s.get(url, auth=HTTPBasicAuth('myUsername', 'myPassword'), verify=False, stream=True)