- 1
name = name.replace(u'c', u'с') # this is magia
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−118
name = name.replace(u'c', u'с') # this is magia
−117
def onRefreshReaders( self, event ):
#try:
self.readersListBox.Clear()
readers = self.burner.getReaders()
if isinstance(readers,BaseException):
raise BaseException("Can't find burner app!")
self.readersListBox.AppendItems( readers)
self.readersListBox.SetSelection( 0 )
#except OSError as e:
#wx.MessageBox("Signer cant be empty!\n", "Error",wx.OK | wx.ICON_ERROR)
qj,fysqhjn
−116
df[df['reason']=='in-in error sequence']['spider'].value_counts().to_csv('spiders_out-out-seq.csv')
Страшно?
−118
def updateLicenseApps( self ):
self.block()
self.statusbarSetLicenseName();
self.applicationGrid.ClearGrid()
if type( self.licenseEditor ) != type( None ):
licparams = self.licenseEditor.licenseApps
....
for x in xrange( len( licparams ) ):
self.applicationGrid.AppendRows( 1, True )
self.applicationGrid.SetCellValue( x, 0, licparams[x]["name"] )
self.applicationGrid.SetCellValue( x, 1, licparams[x]["startdate"] )
MMAXIMUM PYTHON
−115
def _message_handler_thread(self):
self._nick_change_failed = []
while self.running:
msg = self._message_queue.get(True)
text = msg.get_data()
conn = msg.get_connection()
args = text.replace("\r", "").replace("\n", "").split(" ")
command = args[0].upper()
command_args = args[1:]
if command == "NICK":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
else:
ident = self._clients[conn].identifier if self._clients[conn].identifier else None
if not self._set_nick(conn, command_args[0], ident):
self._nick_change_failed.append(conn)
elif command == "USER":
if conn in self._clients:
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
else:
''''
self._send_lusers(conn)
self._clients[conn].real_name = command_args[:]
self._clients[conn].identifier = self._clients[conn].get_nick() + "!" + \
command_args[0] + "@" + self.name
'''
self._set_nick(conn, command_args[0], command_args[1])
self._send_motd(conn)
else: # Another way to identify is USER command.
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
elif conn in self._nick_change_failed:
self._nick_change_failed.remove(conn)
else:
if self._set_nick(conn, command_args[0], command_args[1]):
self._clients[conn].identifier = self._clients[conn].get_nick() + "!" + \
command_args[0] + "@" + self.name
self._send_motd(conn)
elif command == "PRIVMSG" or command == "NOTICE":
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
else:
message_text = command_args[1] if not command_args[1][0] == ":" else \
text.replace("\r\n", "")[text.index(":")+1:]
src = self._clients[conn].get_identifier()
dest = command_args[0]
if not dest.startswith("#"):
for clnt in self._clients.values():
if clnt.nick == dest:
clnt.connection.send(
":%s %s %s :%s" % (src, command, dest, message_text)
)
break
else:
self._send_no_user(conn, dest)
else:
for chan in self._channels:
if chan.name == dest:
self._channel_broadcast(conn, chan, ":%s %s %s :%s" %
(src, command, dest, message_text))
break
else:
self._send_no_user(conn, dest)
elif command == "JOIN":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
elif not all(c in ALLOWED_CHANNEL for c in command_args[0]) and len(command_args[0]):
self._send_no_channel(conn, command_args[0])
else:
for chan in self._channels:
if chan.name == command_args[0]:
chan.users += 1
self._clients[conn].channels.append(chan)
self._send_to_related(conn, ":%s JOIN %s" % (self._clients[conn].get_identifier(),
chan.name), True)
self._send_topic(conn, chan)
self._send_names(conn, chan)
else:
chan = Channel(command_args[0], 1)
chan.users = 1 # We have a user, because we have created it!
self._channels.append(chan)
self._clients[conn].channels.append(chan)
self._clients[conn].send(":%s JOIN %s" % (self._clients[conn].get_identifier(),
command_args[0]))
elif command == "PART":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
else:
for chan in self._channels:
if chan.name == command_args[0]:
self._send_to_related(conn, ":%s PART %s" % (self._clients[conn].get_identifier(),
command_args[0]))
self._clients[conn].channels.remove(chan)
chan.users -= 1
break
...
Я писал сервер для IRC...
Больше говнокода: https://github.com/SopaXorzTaker/irc-server/
−109
result['first'] = False if page != 1 else True
Неплохое такое выражение
−115
def _make_parser_function(name, sep=','):
def parser_f(filepath_or_buffer,
sep=sep,
dialect=None,
compression=None,
doublequote=True,
escapechar=None,
quotechar='"',
quoting=csv.QUOTE_MINIMAL,
skipinitialspace=False,
lineterminator=None,
header='infer',
index_col=None,
names=None,
prefix=None,
skiprows=None,
skipfooter=None,
skip_footer=0,
na_values=None,
na_fvalues=None,
true_values=None,
false_values=None,
delimiter=None,
converters=None,
dtype=None,
usecols=None,
engine='c',
delim_whitespace=False,
as_recarray=False,
na_filter=True,
compact_ints=False,
use_unsigned=False,
low_memory=_c_parser_defaults['low_memory'],
buffer_lines=None,
warn_bad_lines=True,
error_bad_lines=True,
keep_default_na=True,
thousands=None,
comment=None,
decimal=b'.',
parse_dates=False,
keep_date_col=False,
dayfirst=False,
date_parser=None,
memory_map=False,
nrows=None,
iterator=False,
chunksize=None,
verbose=False,
encoding=None,
squeeze=False,
mangle_dupe_cols=True,
tupleize_cols=True,
):
# Alias sep -> delimiter.
if delimiter is None:
delimiter = sep
kwds = dict(delimiter=delimiter,
engine=engine,
dialect=dialect,
compression=compression,
doublequote=doublequote,
escapechar=escapechar,
quotechar=quotechar,
quoting=quoting,
skipinitialspace=skipinitialspace,
lineterminator=lineterminator,
header=header,
index_col=index_col,
names=names,
prefix=prefix,
skiprows=skiprows,
na_values=na_values,
na_fvalues=na_fvalues,
true_values=true_values,
false_values=false_values,
keep_default_na=keep_default_na,
thousands=thousands,
comment=comment,
decimal=decimal,
parse_dates=parse_dates,
keep_date_col=keep_date_col,
dayfirst=dayfirst,
date_parser=date_parser,
nrows=nrows,
iterator=iterator, ....
На самом деле оно в общем не такое уж и страшное потому что в питоне можно по имени аргументы в метод, но флешер в мне нервно икнул
−113
escape_cats = [cat_id for cat_id, values in cats.iteritems() if any([values[1] == supercat or cat_id == supercat for supercat in escape_supercats])]
Избегание котов.
−113
user8@linux ~ $ python
Python 2.7.5 (default, Feb 10 2014, 02:34:23)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> 1-3*(math.exp(1)-2)/math.exp(1)
0.207276647028654
>>> 1-4*(1-3*(math.exp(1)-2)/math.exp(1))
0.17089341188538398
>>> 1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))
0.14553294057308008
>>> 1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))
0.1268023565615195
>>> 1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))
0.11238350406936348
>>> 1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))
0.10093196744509214
>>> 1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))
0.09161229299417073
>>> 1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))
0.0838770700582927
>>> 1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))
0.07735222935878028
>>> 1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))
0.07177324769463667
>>> 1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))
0.06694777996972334
>>> 1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))
0.06273108042387321
>>> 1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))
0.059033793641901866
>>> 1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))
0.05545930172957014
>>> 1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))))
0.05719187059730757
>>> 1-18*(1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))))
-0.029453670751536265
Дано рекуррентное соотношение: x 1 = 1 e , x k = 1 − kx k−1 , k = 2, 3, 4, . . .
Напишите программу, которая вычисляет первые 15 чисел с точностью float и выводит их на экран
−114
cur.execute("""SELECT EXTRACT(dow from DATE %(date)s)""", {"date" : datetime})
week = cur.fetchone()
Я конечно знаю, что ГК про даты это плохой тон, но такого я еще не видел.