Advertisement
rfmonk

ipython_log02.py

Jan 9th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. # IPython log file
  2.  
  3. get_ipython().magic(u'cd Python/')
  4. get_ipython().magic(u'logstart')
  5. str.capitalize()
  6. import string_capwords
  7. s
  8. from string_capwords import *
  9. s
  10. string.capwords(s)
  11. string.capitalize(s)
  12. s
  13. string.capwords(s)
  14. string.ascii_letters(s)
  15. string.atof(s)
  16. string.aatoi(s)
  17. string.atoi(s)
  18. string.atol(s)
  19. string.capitalize(s)
  20. string.capwords(s)
  21. string.digits(s)
  22. string.expandtabs(s)
  23. string.count(s)
  24. str.decode(s)
  25. str.encode(s)
  26. str.endswith(s)
  27. str.find(s)
  28. str.find((s)z)
  29. str.find(s) z
  30. str.find(s[z])
  31. str.find(z[s])
  32. import string
  33. str.find(z) in s
  34. 'z' in s
  35. str.format(s)
  36. "The sum of 1 + 2 is {0}".format(1+2)
  37. str.index(s)
  38. str.isalpha(s)
  39. str.isupper(s)
  40. str.lstrip(s)
  41. s.lstrip(T,q,b)
  42. '    spacious    '.lstrip()
  43. 'www.altsci.com'.lstrip('cmowz.')
  44. 'www.altsci.com'.lstrip('w.')
  45. 'www.altsci.com'.lstrip('.c')
  46. 'www.altsci.com'.lstrip('.com')
  47. 'www.altsci.com'.lstrip('com')
  48. 'www.altsci.com'.lstrip('com.')
  49. 'www.altsci.com'.lstrip('cm.')
  50. 'www.altsci.com'.lstrip('cmoz.')
  51. 'www.altsci.com'.lstrip('w.')
  52. 's'.rsplit(T)
  53. str.rsplit(s)
  54. d = "str.rsplit() Return a list of the words in the string, using sep as the delimiter string. if maxsplit is given, at most maxsplit splits are done, the rightmost ones. if sep is not specified or none, any whitespace string is a seperator. Except for splitting from from the right, rsplit() behaves like split() which is described in detail below."
  55. d
  56. str.rsplit(d)
  57. str.rsplit(d) | less
  58. import textwrap
  59. textwrap.fill.func_defaults()
  60. import textwrap
  61. from textwrap_example import sample_text
  62. dedented_text = textwrap.dedent(sample_text).strip()
  63. print textwrap.fill(dedented_text,
  64.             initial_ident='',
  65.             subsequent_indent=' ' * 4,
  66.             )
  67. def test():
  68.     # end first line with \ to avoid the empty line!
  69.     s = '''\
  70.    hello
  71.      world
  72.    '''
  73.     print repr(s)
  74.     print repr(dedent(s))
  75.    
  76. s
  77. wrapper = TextWrapper(initial_indent="* ")
  78. wrapper = TextWrapper()
  79. wrapper.initial_indent = "* "
  80. import re
  81. pattern = 'this'
  82. text = 'Does this text match the pattern?'
  83. match = re.DEBUG(pattern, text)
  84. match = re.DOTALL(pattern, text)
  85. match = re.I(pattern, text)
  86. match = re.IGNORECASE(pattern, text)
  87. match = re.L(pattern, text)
  88. match = re.LOCALE(pattern, text)
  89. match = re.M(pattern, text)
  90. match = re.MULTILINE(pattern, text)
  91. match = re.S(pattern, text)
  92. match = re.Scanner(pattern, text)
  93. match = re.TEMPLATE(pattern, text)
  94. match = re.U(pattern, text)
  95. match = re.UNICODE(pattern, text)
  96. match = re.VERBOSE(pattern, text)
  97. match = re.X(pattern, text)
  98. match = compile(pattern, text)
  99. match = re.compile(pattern, text)
  100. match = re.copy_reg(pattern, text)
  101. match = re.error(pattern, text)
  102. match = re.escape(pattern, text)
  103. match = re.findall(pattern, text)
  104. s = match.start()
  105. match = re.search(pattern, text)
  106. s = match.start()
  107. e = match.end()
  108. print 'Found "%s"\nin "%s"\nfrom %d to %d ("%s")' % \
  109. (match.re.pattern, match.string, s, e, text[s:e])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement