31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
If you use variable once and in return statment, just return result
return eval('su' + 'm')(data)
More
Python list are not optimized to pop(0) # remove element form begin, you should avoid this in cycles. Replace it with for or reverse list and use pop() # remove element from end.
For each line of log you traverse over all other lines in log. It is to complex. You can break on time_delta more the
More
It is better to accumulate string it list and join them at the end.
res = []
....
res.append(...)
return '\n'.join(res)
More
It is not pythonic to assign lambda to variable, it is better to define it same style as parseLog.
You can skip parenthesis in that case:
# (time, username, URL) = single_log_text.split(";;")
time, username, URL = single_log_text.split(";;")
More
Huge work, some part of it does not covered by checkIO tests.
you can simplify hexdigits by removing [A-F], segments are already in lowercase.
More
PATH_LOWER has no sence.
authority variable can be replaced by host.
no need to convert port to int, it used only as string.
More
Good work, same idea as mine. But I deside to use nested functions instead of class.
This methods are unused: edist, i2c, c2i
More
Code looks very bulky. It is hard to read.
Just some quites form PEP8:
Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).
Comp
More
IMHO **as** in import is usefull only then you have namespace conflicts like:
from gzip import open as gz_open
In other cases it is adds entropy to code.
Current task say "The result is a float from 0 to 1 with two digits precision." you have three.
return round(float(prob(bl
More
When I see string like that: [e[0]-1,e[1]+1,e[2]*e[0]/(e[0]+e[1])] I dont want to understand logic.
To avoid such mess you can use unpacking:
for white, black, step in container:
if white == 0:
And please read about python style (PEP8).
See python documentation for functions y
More
It is common practice to use _ for dummy variable name. I prefer to use __ because _ used in I18N as alias to gettext.
I dont shure it is good to hardcode values, maximum possible rotation = (1 + s1 + s2) * 180
for b1 in [0.0, -360.0, 360.0, -720.0, 720.0]:
If you need to unpack
More
You can use python syntax to simpify code:
for i in range(len(expr))
for char in expr # itrate over chars in string.
if len(brackets) == 0:
if brackets: # empty list is False
brackets[len(brackets)-1]
brackets[-1] # last element is -1 second from end -2 etc.
More
You can use return on length fail.
if len(data) < 10:
return False
Check all function
return all((length, num, caps, low))
Please cleanup you code before publish, this comments are invalid.
# replace this for solution
# Some hints
# Just check a
More
V and S are bad variable names for python.
For multi line docstrings I prefer to start text from second line.
More