Python Macros: Use Cases?

后端 未结 17 2100
甜味超标
甜味超标 2021-01-30 18:37

If Python had a macro facility similar to Lisp/Scheme (something like MetaPython), how would you use it?

If you are a Lisp/Scheme programmer, what sorts of things do y

17条回答
  •  借酒劲吻你
    2021-01-30 18:42

    Possibly if you want the source code at runtime such as for debugging (say printf debugging an expression's value with the name of it so you don't have to write it twice).

    The only way I could think of to do it in python is to pass a string to eval.

提交回复
热议问题