- 1
Зачем нужен "z == int(str(z)[::-1])", если есть "int(str(z)[:len(str(z))//2]) == int(str(z)[int((len(str(z))+1)//2):][::-1])"?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−3
Зачем нужен "z == int(str(z)[::-1])", если есть "int(str(z)[:len(str(z))//2]) == int(str(z)[int((len(str(z))+1)//2):][::-1])"?
−4
stack = []
def stdout(x):
if x == "puts":
print(stack.pop())
else:
raise Exception("иди нахуй")
def stdin(x):
global stack
if x == "gets":
stack.append(input())
else:
raise Exception("иди нахуй")
math = {
"add": lambda: stack.append(float(stack.pop()) + float(stack.pop())),
"sub": lambda: stack.append((-float(stack.pop())) + float(stack.pop())),
"mul": lambda: stack.append(float(stack.pop()) * float(stack.pop())),
"div": lambda: stack.append(1 / float(stack.pop()) * float(stack.pop())),
}
def stack_commands(x):
global stack
if x == "swap":
stack[-1], stack[-2] = stack[-2:]
elif x == "drop":
stack.pop()
elif x == "dup":
stack.append(stack[-1])
else:
raise Exception("иди нахуй")
string = {
"concat": lambda: stack.append(str(stack.pop()) + str(stack.pop()))
}
commands = {
"comment": lambda x: x,
"push": lambda x: stack.append(x),
"stdout": stdout,
"stdin": stdin,
"math": lambda x: print(math[x]()),
"stack": stack_commands,
"string": lambda x: string[x]()
}
def do(x):
if '@' not in x:
raise Exception(x + " is not email.")
a, b = x.split('@')
b = b.split('.')[0]
commands[b](a)
def eval(s):
for i in s.lower().split():
do(i)
eval("""
[email protected]
[email protected] [email protected]
[email protected]
[email protected] [email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected] [email protected] [email protected]
""")
+4
def lookup(self, code):
"""
Looks up code in Redis
Returns None on failure
"""
url = self.redis.get(code)
try:
pass
except:
url = None
return url
Вот такое на полном серьезе получили как кусочек домашнего задания для соискателя на Senior Python Engineer
−2
Помните я потешался над обитателями форума phpclub?
Так вот у питонистов тоже есть такой форум, а там раздел "python для экспертов".
Дай, думаю, зайду, послушаю о чем эксперты лалакают.
Может быть обсуждают не выпилить-ли GIL из CPython?
Или радуются появившимся в 3.7 датаклассам?
А там:
http://python.su/forum/topic/35652/
http://python.su/forum/topic/35479/
http://python.su/forum/topic/35575/
http://python.su/forum/topic/35592/
Такие вот нынче эксперты
−1
https://stackoverflow.com/questions/51521158/in-python-why-does-0xbin-return-false
Свежий обосрамс питона
0
#-*-coding:utf8;-*-
combinators = {
'I': lambda x: x if len(x) <= 1 else calc(x[1:]),
'K': lambda x: x if len(x) <= 2 else calc((x[1],) + x[3:]),
'W': lambda x: x if len(x) <= 2 else calc(x[1:3] + x[2:]),
'S': lambda x: x if len(x) <= 3 else calc((x[1], x[3], (x[2], x[3])) + x[4:]),
'B': lambda x: x if len(x) <= 3 else calc((x[1], (x[2], x[3])) + x[4:]),
'C': lambda x: x if len(x) <= 3 else calc((x[1], x[3], x[2]) + x[4:]),
'U': lambda x: x if len(x) <= 2 else calc((x[2], (x[1], x[1], x[2])) + x[3:]),
'Y': lambda x: x if len(x) <= 1 else calc(('S',('K',('S','I','I')),('S',('S',('K','S'),'K'),('K',('S','I','I')))) + x[2:])
}
def calc(x):
def f(x, top = False):
if type(x) is not tuple or len(x) == 0:
return x
if top:
while type(x[0]) is tuple:
x = x[0] + x[1:]
else:
if type(x[0]) is tuple:
return (calc(x[0]),) + f(x[1:])
print(termrepr(x))
input('Press Enter...')
return combinators.get(x[0], lambda _: (x[0],) + f(x[1:]))(x)
return f(x, True)
def parse(s):
def f(s, n):
res = ()
i = n
while i < len(s):
if s[i] == '(':
t, j = f(s, i + 1)
res += (t,)
i = j - 1
elif s[i] == ')':
return (res, i + 1)
else:
res += (s[i],)
i += 1
return (res, i)
return f(s, 0)[0]
def termrepr(x):
if len(x) == 0:
return ''
if type(x[0]) is tuple:
return '(' + termrepr(x[0]) + ')' + termrepr(x[1:])
else:
return x[0] + termrepr(x[1:])
print('>> ', end = '')
while True:
print(termrepr(calc(parse(input()))))
print('\n>> ', end = '')
Я перепесал #24129:
>> BUGURT
BUGURT
Press Enter...
U(GU)RT
Press Enter...
R((GU)(GU)R)T
Press Enter...
GU(GU)R
Press Enter...
U(GU)R
Press Enter...
R((GU)(GU)R)
Press Enter...
GU(GU)R
Press Enter...
U(GU)R
Press Enter...
−2
import re
brabrebrized = lambda s, repl = r"бр\1": (
re.sub(
"[йцкнгшщзхъфвпрлджчсмтьб]+([аеёиоуыэюя])",
repl,
s,
flags = re.IGNORECASE
)
)
Я ебрабрубря и брабрибрал брабрибраброр бребров. брибрер:
брибрит брёбра бра брабробре,
бробрит ябра в абребробре.
брибрия! брибрия!
бря брабрубра брибряя!
0
('%s'%().__class__)[bool([()])<<(bool([()])<<bool({()}))]+('%s'%bool([{}]))[(bool([()])<<(bool({()})))+(bool([[]]))]+('%s'%None)[bool([()])<<bool({()})]+('%s'%{}.__class__)[bool([()])<<(bool([()])+(bool([[]])<<bool({()})))]+('%s'%None)[bool([])<<bool({()})]+('%s'%().__class__)[19%10]+('%s'%{}.__class__)[bool([()])<<(bool([()])+(bool([[]])<<bool({()})))]+('%s'%bool([]))[bool([()])<<(bool([()])<<bool({()}))]+('%s'%[].__class__)[(bool([()])+(bool([()])<<(bool([[]])<<bool({()}))))*(bool([[]])<<bool({()}))]
+1
def __repr__(self) -> str:
return f"<User{return ', inactive!' if not self.active else ''} #{self.id} ({self.username}/{self.email})>"
Когда очень хочется использовать красивый f"{ormat}" для строки, но модель БД становится все сложнее...
−2
Какой есть аналог класса для данных?
class Record():
pass
r = Record()
r. asd = 1
Заебало класс объявлять, неужели для такого элементарного случая ничего не придумали?