Python论坛  - 讨论区

标题:[python-chinese] 获取函数的__doc__

2006年01月17日 星期二 16:46

Gerald Lee leejd80 at gmail.com
Tue Jan 17 16:46:21 HKT 2006

通过dir我们可以返回一个类的全部函数,如果我想得到某个函数的doc串,该如何操作呢?因为dir得到的函数名称是字符串的,我们不能直接通过__doc__得到。也就是说,代码中的XX部分该如何填写?

代码如下:
----------------
class Fmt:

    def __init__ (self):
        pass

    def TotalPlugin (self):
        """返回所有插件(以G_开头的函数)"""
        l = dir(self)
        Plugin = []
        for item in l:
            if len(item)>2:
                if item[:2]=="G_":
                    temp = []
                    temp.append(item)
                    temp.append(XX.__doc__)
                    Plugin.append(temp)
        return Plugin

--
My Blog >> http://leejd.cndev.org
My QQ >> 9847243
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060117/e04fd211/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年01月17日 星期二 16:54

Slowness Chen chenzh at bhh.com.cn
Tue Jan 17 16:54:42 HKT 2006

> temp.append(XX.__doc__)
temp.append(getattr(self, item).__doc__)

  ----- Original Message ----- 
  From: Gerald Lee
  To: python-chinese at lists.python.cn ; python-cn at googlegroups.com
  Sent: Tuesday, January 17, 2006 4:46 PM
  Subject: [python-chinese] 获取函数的__doc__


  通过dir我们可以返回一个类的全部函数,如果我想得到某个函数的doc串,该如何操作呢?因为dir得到的函数名称是字符串的,我们不能直接通过__doc__得到。也就是说,代码中的XX部分该如何填写?

  代码如下:
  ----------------
  class Fmt:

      def __init__ (self):
          pass

      def TotalPlugin (self):
          """返回所有插件(以G_开头的函数)"""
          l = dir(self)
          Plugin = []
          for item in l:
              if len(item)>2:
                  if item[:2]=="G_":
                      temp = []
                      temp.append(item)
                      temp.append(XX.__doc__)
                      Plugin.append(temp)
          return Plugin

  -- 
  My Blog >> http://leejd.cndev.org
  My QQ >> 9847243


------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese at lists.python.cn
  Subscribe: send subscribe to python-chinese-request at lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060117/8ae34a1e/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年01月17日 星期二 18:44

xinguoyao lixg at zoomtech.com.cn
Tue Jan 17 18:44:01 HKT 2006

I try to install python2.4.2 on solaris.
After "./configure" "make" everything is ok.
When i try to "make install",an error accured!
---------------------------------------------------------------------------------------------
PYTHONPATH=/usr/local/lib/python2.4 ./python -Wi -tt /usr/local/lib/python2.4/compileall.py -d /usr/local/lib/python2.4 -f -x 'badsyntax|site-packages' /usr/local/lib/python2.4
ld.so.1: python: fatal: libstdc++.so.5: open failed: No such file or directory
*** Error code 137
make: Fatal error: Command failed for target `libinstall'
---------------------------------------------------------------------------------------------
Why?
What should I do?
3ks!



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年01月17日 星期二 18:58

Yaou Lee yaoulee at gmail.com
Tue Jan 17 18:58:56 HKT 2006

貌似你的libstdc++.so.5找不到了

去/usr/lib 下面找找 有没有 libstdc++.so.5.0.X 之类的文件 如果有的话就
ln -s 到libstdc++.so.5
没有的话就安装一个libstdc++5吧

Yaou


xinguoyao wrote:

>I try to install python2.4.2 on solaris.
>After "./configure" "make" everything is ok.
>When i try to "make install",an error accured!
>---------------------------------------------------------------------------------------------
>PYTHONPATH=/usr/local/lib/python2.4 ./python -Wi -tt /usr/local/lib/python2.4/compileall.py -d /usr/local/lib/python2.4 -f -x 'badsyntax|site-packages' /usr/local/lib/python2.4
>ld.so.1: python: fatal: libstdc++.so.5: open failed: No such file or directory
>*** Error code 137
>make: Fatal error: Command failed for target `libinstall'
>---------------------------------------------------------------------------------------------
>Why?
>What should I do?
>3ks!
>
>
>_______________________________________________
>python-chinese
>Post: send python-chinese at lists.python.cn
>Subscribe: send subscribe to python-chinese-request at lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>  
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号