[ create a new paste ] login | about

python@2ch

Name:
Email:
Site/Blog:
Location:
Default language:
Favorite languages:
About:

Saved pastes by python@2ch:

Python, pasted on Jun 29:
1
2
3
4
5
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)
Python, pasted on Jun 28:
1
2
3
4
5
from timeit import Timer

VALUE = 1

def bool_test():
...
view (17 lines, 3 lines of output)
Python, pasted on Jun 28:
1
2
3
4
from timeit import Timer

print Timer('bool(1)').timeit()
#0.42471152059828832
...
view (10 lines, 3 lines of output)
Python, pasted on Jun 22:
1
2
3
4
5
# -*- coding: utf-8 -*-

def indexing(str):
    '''
    >>> indexing(u'アメリカ合衆国')
...
view (28 lines, 13 lines of output)
Python, pasted on Jun 17:
1
2
3
4
5
def gnext():
  '''
  >>> gnext()
  pochi
  >>> gnext()
...
view (24 lines, 32 lines of output)
Python, pasted on Jun 12:
1
2
3
4
5
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)
Python, pasted on Jun 12:
1
2
3
4
5
def hello(s):
  """
  >>> hello("world")
  'hello world'
  """
...
view (55 lines, 58 lines of output)
Python, pasted on Jun 11:
1
2
3
4
5
>>> MULTI='''
... %(no)s. %(name)s %(year)d/%(month)d/%(day)d
... %(__name__)s
... '''
>>> for key in re.findall('(?!.*s)%\((.*?)\)d', MULTI):
...
view (47 lines)
Python, pasted on Jun 11:
1
2
3
4
5
>>> temp='Issac Asimov'
>>>
>>> for key in re.findall('Issac (?!Asimov)', temp):
...   print key
...
...
view (29 lines)