class Queue:
def __init__(self, *array):
self.array = []
for el in array:
self.array.append(el)
self.generator = self.__gen()
def __str__(self):
string = ['[']
for el in self.array:
string.append(str(el))
string.append(' -> ')
del string[-1]
string.append(']')
string = ''.join(string)
return string
def next(self):
new_array = self.array[1::]
return Queue(*new_array)
def __gen(self):
l = len(self.array)
for i in range(1,l):
new_array = self.array[i:]
yield Queue(*new_array)
def __next__(self):
try:
n = next(self.generator)
except StopIteration:
n = None
return n
q1 = Queue(1, 2, 3, 4)
q2 = q1.next()
print(q1)
print(q2)
q3 = next(q1)
print(q3)
q3 = next(q1)
print(q3)
q3 = next(q1)
print(q3)
q3 = next(q1)
print(q3)
pow(b, 1) + pow(c, 2) - pow(a, 2) > 0
import requests
import re
url = 'https://kase.kz/ru/trades/'
r = requests.get(url)
cookie_header = r.headers['Set-Cookie']
cookie = re.search('csrftoken=([\s\S]+?);', cookie_header).group(1)
print cookie
cookies = {
'csrftoken': cookie,
'TRADE_USER_SETTINGS_FOREX': '"{\"fields\": [3]\054 \"instruments\": [\"USDKZT_TOD\"]}"',
}
data = {
'csrfmiddlewaretoken': cookie,
'market': 'FOREX',
'instrument': 'USDKZT_TOD',
'field': '3',
}
r = requests.post('https://kase.kz/ru/trades/view/', cookies=cookies, data=data)
print r.status_code
print r.text
import falcon
import json
class CResourse(object):
def on_post(self, req, res):
data = json.load(req.stream)
res.status = falcon.HTTP_200
res.body = 'ddd'
app = falcon.API()
app.add_route('/callback', CResourse())