- 1
- 2
- 3
- 4
- 5
- 6
import ctypes, sys
if ctypes.windll.shell32.IsUserAnAdmin():
if __name__ == "__main__":
main()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
import ctypes, sys
if ctypes.windll.shell32.IsUserAnAdmin():
if __name__ == "__main__":
main()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
Ав тозапуск с пра вами адми нис тра тора
Для авто запус ка мы будем исполь зовать сле дующий код:
Те перь при попыт ке запус тить скрипт вызов будет передан на UAC (если акти‐
вен) и откро ется новое окно тер минала, где наш код выпол нится от име ни
адми нис тра тора.
Ес ли такой вари ант не устра ивает, то всег да мож но вос поль зовать ся
готовы ми решени ями.
--------------
Ксакеп. if __name__ == "__main__" не там стоит, автор не понял что это такое.
−1
# -- coding: cp866 --
https://github.com/h4ckzard/wpseyes/blob/master/Windows/wpseyes.py
В чём это писалось???
0
class list(list):
def __call__(self, *args):
if len(args) == 0:
return self[:]
res = []
for i in args:
if type(i) == int:
res.append(self[i])
else:
res.append(self(*i) if len(i) != 1 else [[[self(0)]]])
return res
a = list(map(lambda x: x * x, range(10)))
print(a(1,0,(6,6,(5,4,3,(0)),6),3,2,(),8,))
Ебат, как добавить список с одним елементом?
https://ideone.com/Fik3PF
+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'], [], [], [], []]
ЧЗХ?