You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
830 B

7 years ago
7 years ago
  1. Libraries
  2. =========
  3. Plot
  4. ----
  5. ```
  6. import matplotlib
  7. matplotlib.pyplot.plot(<data>, ...)
  8. matplotlib.pyplot.show()
  9. matplotlib.pyplot.savefig(<filename>)
  10. ```
  11. Web
  12. ---
  13. ```
  14. import bottle
  15. ```
  16. ### Run
  17. ```
  18. bottle.run(host='localhost', port=8080)
  19. bottle.run(host='0.0.0.0', port=80, server='cherypy')
  20. ```
  21. ### Static request
  22. ### Dynamic request
  23. ### REST request
  24. Curses
  25. ------
  26. ```
  27. import curses
  28. def main():
  29. curses.wrapper(draw)
  30. def draw(screen):
  31. screen.clear()
  32. screen.addstr(0, 0, "Press ESC to quit.")
  33. while screen.getch() != 27:
  34. pass
  35. ```
  36. Profile
  37. -------
  38. ```
  39. import timeit
  40. timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
  41. ```
  42. ```
  43. import pycallgraph
  44. graph = pycallgraph.output.GraphvizOutput()
  45. graph.output_file = <filename>
  46. with pycallgraph.PyCallGraph(output=graph):
  47. <code>
  48. ```