METADATA 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Metadata-Version: 2.0
  2. Name: MacroPy
  3. Version: 1.0.3
  4. Summary: Macros for Python: Quasiquotes, Case Classes, LINQ and more!
  5. Home-page: https://github.com/lihaoyi/macropy
  6. Author: Li Haoyi, Justin Holmgren
  7. Author-email: haoyi.sg@gmail.com, justin.holmgren@gmail.com
  8. License: MIT
  9. Platform: UNKNOWN
  10. Classifier: Programming Language :: Python :: 2.7
  11. Provides-Extra: js_snippets
  12. Requires-Dist: pjs; extra == 'js_snippets'
  13. Requires-Dist: selenium; extra == 'js_snippets'
  14. Provides-Extra: pinq
  15. Requires-Dist: SQLAlchemy; extra == 'pinq'
  16. Provides-Extra: pyxl
  17. Requires-Dist: pyxl; extra == 'pyxl'
  18. MacroPy is an implementation of Macros in the Python Programming Language.
  19. MacroPy provides a mechanism for user-defined functions (macros) to perform
  20. transformations on the abstract syntax tree(AST) of Python code at module
  21. import time. This is an easy way to modify the semantics of a python program
  22. Python like you've never seen before
  23. ------------------------------------
  24. MacroPy allows you to create constructs which are impossible to have in normal
  25. python code, such as:
  26. Tracing
  27. ```````
  28. .. code:: python
  29. with trace:
  30. sum([x + 5 for x in range(3)])
  31. # sum([x + 5 for x in range(3)])
  32. # range(3) -> [0, 1, 2]
  33. # x + 5 -> 5
  34. # x + 5 -> 6
  35. # x + 5 -> 7
  36. # [x + 5 for x in range(3)] -> [5, 6, 7]
  37. # sum([x + 5 for x in range(3)]) -> 18
  38. Quick Lambdas
  39. `````````````
  40. .. code:: python
  41. print map(f[_[0]], ['omg', 'wtf', 'bbq'])
  42. # ['o', 'w', 'b']
  43. print reduce(f[_ + _], ['omg', 'wtf', 'bbq'])
  44. # 'omgwtfbbq
  45. Case Classes
  46. ````````````
  47. .. code:: python
  48. @case
  49. class Point(x, y): pass
  50. p = Point(1, 2)
  51. print str(p) #Point(1, 2)
  52. print p.x #1
  53. print p.y #2
  54. print Point(1, 2) == Point(1, 2) # True
  55. And more! All this runs perfectly on vanilla Python 2.7 or PyPy 2.0. For more
  56. details, see the `GitHub page <https://github.com/lihaoyi/macropy#macropy>`_.
  57. or ask in the `Google Group <https://groups.google.com/forum/#!forum/macropy>`_.