zoukankan      html  css  js  c++  java
  • python 打印类的属性、方法

    打印变量db的类(class):
    [root@fuel ~]# python
    Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from nailgun.db import db
    2016-01-28 15:33:57.512 DEBUG [7fa46d13f700] (settings) Looking for settings.yaml package config using old style __file__
    2016-01-28 15:33:57.512 DEBUG [7fa46d13f700] (settings) Trying to read config file /usr/lib/python2.6/site-packages/nailgun/settings.yaml
    2016-01-28 15:33:57.733 DEBUG [7fa46d13f700] (settings) Trying to read config file /etc/nailgun/settings.yaml
    2016-01-28 15:33:57.752 DEBUG [7fa46d13f700] (settings) Trying to read config file /etc/fuel/version.yaml
    >>> print db.__class__
    <class 'sqlalchemy.orm.scoping.scoped_session'>
    >>> print db.__class__.__name__
    scoped_session
    >>> exit()



    # vi a.py
    ----------------------------------------------------------------
    import re
    from sqlalchemy.orm.scoping import scoped_session
    d = scoped_session.__dict__
    for var in d:
        p = re.compile("__.*__")
        m = p.search(var)
        if m == None:
            print "object.%s=%s" % (var, d[var])
    ----------------------------------------------------------------
    # python a.py
    object.add_all=<function do at 0x22a8050>
    object.no_autoflush=<property object at 0x22a7310>
    object.expunge_all=<function do at 0x22a8578>
    object.scalar=<function do at 0x22a8938>
    object.query=<function do at 0x22a87d0>
    object.close_all=<classmethod object at 0x22a9398>
    object.add=<function do at 0x22a5f50>
    object.rollback=<function do at 0x22a88c0>
    object.configure=<function configure at 0x22a5cf8>
    object.query_property=<function query_property at 0x22a5d70>
    object.is_active=<property object at 0x22a7260>
    object.is_modified=<function do at 0x22a86e0>
    object.info=<property object at 0x22a7368>
    object.execute=<function do at 0x22a8398>
    object.expunge=<function do at 0x22a8500>
    object.refresh=<function do at 0x22a8848>
    object.autoflush=<property object at 0x22a72b8>
    object.merge=<function do at 0x22a8758>
    object.dirty=<property object at 0x22a7100>
    object.begin_nested=<function do at 0x22a8140>
    object.delete=<function do at 0x22a8320>
    object.remove=<function remove at 0x22a5c80>
    object.flush=<function do at 0x22a85f0>
    object.close=<function do at 0x22a81b8>
    object.new=<property object at 0x22a71b0>
    object.begin=<function do at 0x22a80c8>
    object.identity_key=<classmethod object at 0x22a9478>
    object.deleted=<property object at 0x22a7158>
    object.identity_map=<property object at 0x22a7208>
    object.expire=<function do at 0x22a8410>
    object.object_session=<classmethod object at 0x22a9408>
    object.bind=<property object at 0x22a70a8>
    object.expire_all=<function do at 0x22a8488>
    object.connection=<function do at 0x22a82a8>
    object.commit=<function do at 0x22a8230>
    object.get_bind=<function do at 0x22a8668>


  • 相关阅读:
    又快又准的sql瓶颈诊断方法
    Qps从300到1500的优化过程
    Mysql性能优化全揭秘-庖丁解牛
    java学习笔记16-抽象类
    java学习笔记15-封装
    java学习笔记14-多态
    java学习笔记13-重写与重载
    Git学习笔记08-远程仓库
    Python3+Appium学习笔记09-元素定位android_uiautomator
    Python3+Appium学习笔记08-元素定位
  • 原文地址:https://www.cnblogs.com/endoresu/p/5166494.html
Copyright © 2011-2022 走看看