推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
billychow
V2EX  ›  Python

如何在静态方法中获得当前调用的上下文?

  •  
  •   billychow ·
    billychow · Aug 25, 2010 · 6409 views
    This topic created in 5875 days ago, the information mentioned may be changed or developed.
    在静态方法内部如何得知当前静态方法是哪一个类的?
    我在里面试着 dir() 了一下,MS 只有传递进来的参数。

    请高人指点,谢谢。
    5 replies  •  1970-01-01 08:00:00 +08:00
    billychow
        1
    billychow  
    OP
       Aug 25, 2010
    或许可以用 call stack 实现?
    iwinux
        2
    iwinux  
       Aug 25, 2010
    用 @classmethod ? 不过这样就变成类方法了...
    billychow
        3
    billychow  
    OP
       Aug 25, 2010
    也行,类方法是绑定的,我刚开始可能就问错了。。。
    那么如果是类方法该怎么做呢?
    iwinux
        4
    iwinux  
       Aug 25, 2010
    billychow
        5
    billychow  
    OP
       Aug 25, 2010
    非常感谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2649 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:52 · PVG 16:52 · LAX 01:52 · JFK 04:52
    ♥ Do have faith in what you're doing.