rebeccaMyKid
V2EX  ›  问与答

[小白] Python 怎么查看函数的调用顺序?

  •  
  •   rebeccaMyKid · May 27, 2017 · 2058 views
    This topic created in 3357 days ago, the information mentioned may be changed or developed.
    大大们,就是我在用一个库,继承了一个类后重写了一个方法,有两个参数我想看看是怎么传进来的,所以我想看一下函数调用的顺序,就是往上找,看可以从哪里改,把自己想要的东西传进去,这个应该怎么做?有简单的方法吗?
    2 replies    2017-05-28 10:43:50 +08:00
    felinx
        1
    felinx  
       May 27, 2017
    可以试试 inspect

    ```
    import inspect


    def a():
    print "a"
    b()


    def b():
    frame = inspect.currentframe()
    print frame.f_back.f_code

    a()
    ```
    troywinter
        2
    troywinter  
       May 28, 2017
    難道不是直接 debug 嗎?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1571 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:31 · PVG 00:31 · LAX 09:31 · JFK 12:31
    ♥ Do have faith in what you're doing.