V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
rebeccaMyKid
V2EX  ›  问与答

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

  •  
  •   rebeccaMyKid · 2017-05-27 11:23:01 +08:00 · 1620 次点击
    这是一个创建于 2539 天前的主题,其中的信息可能已经有所发展或是发生改变。
    大大们,就是我在用一个库,继承了一个类后重写了一个方法,有两个参数我想看看是怎么传进来的,所以我想看一下函数调用的顺序,就是往上找,看可以从哪里改,把自己想要的东西传进去,这个应该怎么做?有简单的方法吗?
    2 条回复    2017-05-28 10:43:50 +08:00
    felinx
        1
    felinx  
       2017-05-27 11:52:13 +08:00
    可以试试 inspect

    ```
    import inspect


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


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

    a()
    ```
    troywinter
        2
    troywinter  
       2017-05-28 10:43:50 +08:00
    難道不是直接 debug 嗎?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5524 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:46 · PVG 11:46 · LAX 20:46 · JFK 23:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.