- 1
- 2
- 3
- 4
- 5
- 6
( '''' )
( 3 ) : 'HELLO-FORTH ." Hello, Forth!" BEGIN REFILL 0= UNTIL ; 'HELLO-FORTH
echo 'Hello, J!'
print =: ]
NB.''')
print('Hello, Python!')
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
( '''' )
( 3 ) : 'HELLO-FORTH ." Hello, Forth!" BEGIN REFILL 0= UNTIL ; 'HELLO-FORTH
echo 'Hello, J!'
print =: ]
NB.''')
print('Hello, Python!')
1. Forth
2. J
3. Python1
4. Python2
5. Python3
+2
print(__import__('pickle').loads(b'c__builtin__\ngetattr\n(c__builtin__\nlist\n(c__builtin__\nmap\n(c__builtin__\neval\n(S\'(lambda x:(lambda y:[x.__setitem__(0,(x[0]+2)**0.5),x.__setitem__(1,x[1]*x[0]/2),2/x[1]][2]))\'\ntR((I0\nI1\nltRc__builtin__\nxrange\n(I27\ntRtRtRS\'__getitem__\'\ntR(I-1\ntR.'))
https://wandbox.org/permlink/sdhWOEIBVq3iiDgF
0
while True:
prev_word = next_word
if next_word.is_empty():
next_word = random.choice(words)
else:
next_word = chain.get_next_word(next_word.root, lambda: Text.Word(''))
suffix = suffix_chain.get_next_word((prev_word.suffix, next_word.root), lambda: '')
if len(suffix) == 0:
suffix = next_word.suffix
punct = punct_chain.get_next_word(next_word.root, lambda: '')
if len(output_words) == 0 or output_words[-1].is_ending_word():
res_word = Text.PunctedWord(next_word.root.capitalize(), suffix, punct)
else:
res_word = Text.PunctedWord(next_word.root, suffix, punct)
output_words += [res_word]
generated_chars += len(res_word)
if chars_max_count > 0 and generated_chars > chars_max_count:
break
if words_max_count > 0 and len(output_words) > words_max_count:
break
Вореции. Генерации. Кобенации. Теперь в энтерпрайз почти ООП-стиле!
s: https://github.com/gost-gk/vorec-enterprise
+1
def enum(x):
globals().update(map(reversed, enumerate(x.split())))
enum("""
ONE
TWO
THREE
FORTH
""")
Forth влияет...
0
def is_regular_pay(self, order):
return order.account is None
def is_card_binding(self, order):
return order.account != None
...
if self.is_regular_pay(order):
...
return HttpResponse("OK", status=200)
elif self.is_card_binding(order):
...
start_cancel_request(order)
else:
get_logger().warn("Unknown successefull operation")
order.save()
−1
x += [random.randint(1,5)*2-1] # здесь мог бы быть random.choice([1,3,7,9])
input()
if 1 in x:
# . . .
# . . .
elif 5 in x:
# А как мне заимплементить случай с пятеркой???7
Когда забываешь о random.choice([...])
+2
from itertools import groupby
In [31]: [list(g) for k, g in groupby('AAAABBBCCDAABBB')]
Out[31]:
[['A', 'A', 'A', 'A'],
['B', 'B', 'B'],
['C', 'C'],
['D'],
['A', 'A'],
['B', 'B', 'B']]
In [30]: [list(g) for k, g in list(groupby('AAAABBBCCDAABBB'))]
Out[30]: [[], ['B'], [], [], [], []]
ЧЗХ?
+2
class Test(contextlib.ExitStack):
def __init__(self):
super().__init__()
with contextlib.ExitStack() as s:
self.foo = s.enter_context(Foo())
self.bar = s.enter_context(Bar())
self.enter_context(s.pop_all())
Неужели в питоне нет более адекватного способа описать класс, который держит джва ресурса и корректно их освобождает во всех ситуациях? И эти люди ругают кресты за сложность управления памятью...
−12
#Было:
sorted(lst, key=lambda x: x['key'])
#или
sorted(lst, key=operator.itemgetter('key')
#стало:
sorted(lst, key=S_['key'])
Говнокоданы, как вам такая идея?
0
import re
def krpt(x):
x = x.group(1)
f = lambda x: "".join(filter(lambda x: x not in "АЕЁИОУЫЭЮЯ", x))
xp = f(x)
if len(xp) == 0:
return x
for i in open("dict.txt", "r"):
i = i.strip().upper()
t = f(i)
if len(t) < len(xp): continue
if xp == t[:len(xp)]:
return i
return x
def KRPT(x):
return re.sub("([А-ЯЁ]+)", krpt, x.upper())
while "ПРЛС":
print(KRPT(input("> ")))
> какой багор )))
АКАКИЙ БОГОРОДСК )))
> лунная клизма, лай мне в анус
АЛИНИН КЛИЗМА, ЛЕЙБНИЦ АМУНДСЕН АВИВ АНИСИЯ
> какой-то ебень написал поебень
АКАКИЙ-АООТ БЕНЬЯМИН НАПИСАЛА ПОЕБЕНЬ
>