python@2ch
|
codepad
|
|
python@2ch
|
Saved pastes by python@2ch:
from timeit import Timer
print Timer('x=[1,2]; x=[i*2 for i in x]').timeit()
# py3k: 2.0419500243746063
# py25: 1.5092940583230501
|
view (9 lines, 1 line of output) |
def finder(reg_str):
'''
>>> finder('[a-z]=[0-9]')
['a=1', 'b=2', 'c=3']
>>> finder('([a-z])=[0-9]')
|
view (43 lines, 6 lines of output) |
>>> MULTI='''
... %(no)s. %(name)s %(year)d/%(month)d/%(day)d
... %(__name__)s
... '''
>>> for key in re.findall('(?!.*s)%\((.*?)\)d', MULTI):
|
view (47 lines) |