spacepaste

  1.  
  2. [pulec@archus python]$ ipython
  3. Python 3.5.2 (default, Jun 28 2016, 08:46:01)
  4. Type "copyright", "credits" or "license" for more information.
  5. IPython 5.1.0 -- An enhanced Interactive Python.
  6. ? -> Introduction and overview of IPython's features.
  7. %quickref -> Quick reference.
  8. help -> Python's own help system.
  9. object? -> Details about 'object', use 'object??' for extra details.
  10. In [1]: import re, json
  11. ...:
  12. ...: #define RIL html file and compile regex for base url
  13. ...: ril_file = '/home/pulec/ril_export_www.html'
  14. ...: re_http_link = re.compile = ".*(http://[\w.-]+)"
  15. ...:
  16. ...: #load RIL file and put all in ril_data list
  17. ...: with open(ril_file, 'r') as ril_file_h:
  18. ...: ril_data = ril_file_h.read().split('\n')
  19. ...:
  20. In [2]: ril_data[1]
  21. ERROR:root:Internal Python error in the inspect module.
  22. Below is the traceback from this internal error.
  23. Traceback (most recent call last):
  24. File "/usr/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
  25. exec(code_obj, self.user_global_ns, self.user_ns)
  26. File "<ipython-input-2-c935d39c02d5>", line 1, in <module>
  27. ril_data[1]
  28. File "/usr/lib/python3.5/site-packages/IPython/core/displayhook.py", line 243, in __call__
  29. if result is not None and not self.quiet():
  30. File "/usr/lib/python3.5/site-packages/IPython/core/displayhook.py", line 94, in quiet
  31. tokens = list(tokenize.generate_tokens(sio.readline))
  32. File "/usr/lib/python3.5/tokenize.py", line 601, in _tokenize
  33. pseudomatch = _compile(PseudoToken).match(line, pos)
  34. File "/usr/lib/python3.5/tokenize.py", line 173, in _compile
  35. return re.compile(expr, re.UNICODE)
  36. TypeError: 'str' object is not callable
  37. During handling of the above exception, another exception occurred:
  38. Traceback (most recent call last):
  39. File "/usr/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 1821, in showtraceback
  40. stb = value._render_traceback_()
  41. AttributeError: 'TypeError' object has no attribute '_render_traceback_'
  42. During handling of the above exception, another exception occurred:
  43. Traceback (most recent call last):
  44. File "/usr/lib/python3.5/site-packages/IPython/core/ultratb.py", line 1132, in get_records
  45. return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  46. File "/usr/lib/python3.5/site-packages/IPython/core/ultratb.py", line 313, in wrapped
  47. return f(*args, **kwargs)
  48. File "/usr/lib/python3.5/site-packages/IPython/core/ultratb.py", line 358, in _fixed_getinnerframes
  49. records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  50. File "/usr/lib/python3.5/inspect.py", line 1453, in getinnerframes
  51. frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
  52. File "/usr/lib/python3.5/inspect.py", line 1414, in getframeinfo
  53. lines, lnum = findsource(frame)
  54. File "/usr/lib/python3.5/site-packages/IPython/core/ultratb.py", line 223, in findsource
  55. pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
  56. TypeError: 'str' object is not callable
  57. ---------------------------------------------------------------------------
  58. [pulec@archus python]$ python
  59. Python 3.5.2 (default, Jun 28 2016, 08:46:01)
  60. [GCC 6.1.1 20160602] on linux
  61. Type "help", "copyright", "credits" or "license" for more information.
  62. >>> import re, json
  63. >>>
  64. >>> #define RIL html file and compile regex for base url
  65. ... ril_file = '/home/pulec/ril_export_www.html'
  66. >>> re_http_link = re.compile = ".*(http://[\w.-]+)"
  67. >>>
  68. >>> #load RIL file and put all in ril_data list
  69. ...
  70. >>> with open(ril_file, 'r') as ril_file_h:
  71. ... ril_data = ril_file_h.read().split('\n')
  72. ...
  73. >>> ril_data[1]
  74. '<li><a href="http://www-cs-students.stanford.edu/~amitp/game-programming/" time_added="1424841193" tags="">Index of /~amitp/game-programming</a></li>'
  75. >>> re.match(re_http_link, ril_data[1]).group(1)
  76. 'http://www-cs-students.stanford.edu'
  77.