V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
wellhome
V2EX  ›  Python

求一个工具能够实时显示对象 type 和 attribute 的

  •  
  •   wellhome · 2017-04-21 08:23:45 +08:00 · 2362 次点击
    这是一个创建于 2559 天前的主题,其中的信息可能已经有所发展或是发生改变。
    小弟刚学 python , 在写代码时候, 经常需要实时知道某个 object 的 type 以及它的 attribute.
    我现在的笨办法是加入 print type 和 print dir.
    有没有更好的办法?
    12 条回复    2017-04-22 08:13:08 +08:00
    bazingaterry
        1
    bazingaterry  
       2017-04-21 08:28:44 +08:00 via iPhone
    PyCharm 。

    要是没法提示也没办法,谁让 Python 是动态类型的...
    xiaket
        2
    xiaket  
       2017-04-21 08:35:25 +08:00
    多写就好了, 写到后面你不用 type 和 dir 就知道这个类型有哪些属性 /方法了.
    adexbn
        3
    adexbn  
       2017-04-21 09:44:14 +08:00 via iPhone
    找对象不靠工具的亲,靠真诚^_^
    容易#2 ,写多了就好了
    unoyx
        4
    unoyx  
       2017-04-21 09:56:53 +08:00
    开个 ipython,然后各种 help.
    xrlin
        5
    xrlin  
       2017-04-21 10:07:15 +08:00 via iPhone
    这就是动态类型语言开发起来不舒服的地方。
    bonfy
        6
    bonfy  
       2017-04-21 10:12:45 +08:00 via iPhone
    @xrlin 享受了便利 有些地方還是要还的
    wellhome
        7
    wellhome  
    OP
       2017-04-21 10:40:33 +08:00
    @xrlin 自己建立的东西是知道返回的类型,
    但是调用第三方库的时候 返回的东西稀奇古怪, 一个 dict 潜入一个 dict ,然后再嵌入 method, list 等, 疯了。
    suueyoung
        8
    suueyoung  
       2017-04-21 11:24:52 +08:00
    当时就是被一个 1(str), 1(int)搞得没有 pycharm 就不写 python.
    xrlin
        9
    xrlin  
       2017-04-21 12:29:50 +08:00
    @wellhome 如果一开始就严格约定好规范, 写好注释,自己写点项目还是挺好的, 但是第三方库或者多人团队合作就容易出问题, 即使是 pycharm 也不能进行完美的分析提示, 如果你写 ruby 你会更凌乱.
    xrlin
        10
    xrlin  
       2017-04-21 12:32:16 +08:00
    @bonfy 是啊, 好想有一门如 python 简洁却是静态类型, 能进行编译时检查的语言.
    wellhome
        11
    wellhome  
    OP
       2017-04-21 12:53:44 +08:00 via iPhone
    @xrlin 用冗余换严谨,世界上的确没有鱼和熊掌都得的好事, java 十年内还是不型项目主流
    wellsc
        12
    wellsc  
       2017-04-22 08:13:08 +08:00 via iPad
    @xrlin julia 可以做到
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5367 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:29 · PVG 17:29 · LAX 02:29 · JFK 05:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.