Python论坛  - 讨论区

标题:[python-chinese] 新手问题,关于DocStrings

2007年02月15日 星期四 01:17

Li Chunhui lich在dhc.com.cn
星期四 二月 15 01:17:40 HKT 2007

_doc_ ºÍ __doc__ ²»Í¬£¬ÄãÉÙÁËÒ»¶Ô _

  ----- Original Message ----- 
  From: »áÀíÏÄ
  To: python-chinese在lists.python.cn
  Sent: Wednesday, February 14, 2007 9:03 AM
  Subject: [python-chinese] ÐÂÊÖÎÊÌ⣬¹ØÓÚDocStrings


  ÎÒÕýÔÚ¿´¡¶¼òÃ÷ Python ½Ì³Ì¡·£¬ÆäÖÐÒ»ÀýÈçÏ£º

  Àý7.8 ʹÓÃDocStrings

  #!/usr/bin/python
  # Filename: func_doc.py

  def printMax(x, y):
      '''Prints the maximum of two numbers.

      The two values must be integers.'''
      x = int(x) # convert to integers, if possible
      y = int(y)

      if x > y:
          print x, 'is maximum'
      else:
          print y, 'is maximum'

  printMax(3, 5)
  print printMax.__doc__

  £¨Ô´Îļþ£ºcode/func_doc.py£©

  Êä³ö
  $ python func_doc.py
  5 is maximum
  Prints the maximum of two numbers.

          The two values must be integers.


  µ«ÊÇÎÒÔËÐÐʱ£¬È´µÃµ½ÈçÏ»ØÏÔ£º

  5 is maximum

  Traceback (most recent call last):
    File "D:\Python25\func_doc.py", line 16, in 
      print printMax._doc_
  AttributeError: 'function' object has no attribute '_doc_'

  googleÁËһϣ¬Ã»ÓÐÕÒµ½´ð°¸£¬msÕâλÐÖµÜÒ²ºÍÎÒÊÇͬһ¸öÎÊÌâ

  Çë´ïÈ˴ͽ̣¬thx



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


  _______________________________________________
  python-chinese
  Post: send python-chinese在lists.python.cn
  Subscribe: send subscribe to python-chinese-request在lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070214/594899ae/attachment.htm 

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

2007年02月14日 星期三 19:11

朱家发 goowelane在gmail.com
星期三 二月 14 19:11:17 HKT 2007

Ç°ºó¶¼ÊÇË«Ï»®Ïß¡£

ÔÚ07-2-15£¬Li Chunhui <lich在dhc.com.cn> дµÀ£º
>
>  _doc_ ºÍ __doc__ ²»Í¬£¬ÄãÉÙÁËÒ»¶Ô _
>
>
>  ----- Original Message -----
> *From:* »áÀíÏÄ <alovei0927在gmail.com>
> *To:* python-chinese在lists.python.cn
> *Sent:* Wednesday, February 14, 2007 9:03 AM
> *Subject:* [python-chinese] ÐÂÊÖÎÊÌ⣬¹ØÓÚDocStrings
>
>
> ÎÒÕýÔÚ¿´¡¶¼òÃ÷ Python ½Ì³Ì¡·£¬ÆäÖÐÒ»ÀýÈçÏ£º
>
> Àý7.8 ʹÓÃDocStrings
>
> #!/usr/bin/python
> # Filename: func_doc.py
>
> def printMax(x, y):
>     '''Prints the maximum of two numbers.
>
>     The two values must be integers.'''
>     x = int(x) # convert to integers, if possible
>     y = int(y)
>
>     if x > y:
>         print x, 'is maximum'
>     else:
>         print y, 'is maximum'
>
> printMax(3, 5)
> print printMax.__doc__
>
> £¨Ô´Îļþ£ºcode/func_doc.py£©
> Êä³ö
>
> $ python func_doc.py
> 5 is maximum
> Prints the maximum of two numbers.
>
>         The two values must be integers.
>
> µ«ÊÇÎÒÔËÐÐʱ£¬È´µÃµ½ÈçÏ»ØÏÔ£º
>
> 5 is maximum
>
> Traceback (most recent call last):
>   File "D:\Python25\func_doc.py", line 16, in 
>     print printMax._doc_
> AttributeError: 'function' object has no attribute '_doc_'
>
> googleÁËһϣ¬Ã»ÓÐÕÒµ½´ð°¸£¬msÕâλÐÖµÜ<http://mailman.linuxchix.org/pipermail/techtalk/2004-April/018394.html>
> Ò²ºÍÎÒÊÇͬһ¸öÎÊÌâ
>
> Çë´ïÈ˴ͽ̣¬thx
>
> ------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
±±Æû¸£ÌïÆû³µ¹¤³ÌÑо¿Ôº³ËÓóµËù
                       Öì¼Ò·¢
                   010-59912466
                    15980725004
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070214/853be0f4/attachment.htm 

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

2007年02月14日 星期三 22:51

会理夏 alovei0927在gmail.com
星期三 二月 14 22:51:49 HKT 2007

Ô­À´ÊÇÕâÑù£¬ÊÇÎÒÌ«´ÖÐÄÁË£¬Ð»Ð»Li ChunhuiºÍÖì¼Ò·¢¡£

ÔÚ07-2-14£¬Öì¼Ò·¢ <goowelane在gmail.com> дµÀ£º
>
> Ç°ºó¶¼ÊÇË«Ï»®Ïß¡£
>
> ÔÚ07-2-15£¬Li Chunhui <lich在dhc.com.cn> дµÀ£º
> >
> >  _doc_ ºÍ __doc__ ²»Í¬£¬ÄãÉÙÁËÒ»¶Ô _
> >
> >
> >  ----- Original Message -----
> > *From:* »áÀíÏÄ <alovei0927在gmail.com>
> > *To:* python-chinese在lists.python.cn
> > *Sent:* Wednesday, February 14, 2007 9:03 AM
> > *Subject:* [python-chinese] ÐÂÊÖÎÊÌ⣬¹ØÓÚDocStrings
> >
> >
> > ÎÒÕýÔÚ¿´¡¶¼òÃ÷ Python ½Ì³Ì¡·£¬ÆäÖÐÒ»ÀýÈçÏ£º
> >
> > Àý7.8 ʹÓÃDocStrings
> >
> > #!/usr/bin/python
> > # Filename: func_doc.py
> >
> > def printMax(x, y):
> >     '''Prints the maximum of two numbers.
> >
> >     The two values must be integers.'''
> >     x = int(x) # convert to integers, if possible
> >     y = int(y)
> >
> >     if x > y:
> >         print x, 'is maximum'
> >     else:
> >         print y, 'is maximum'
> >
> > printMax( 3, 5)
> > print printMax.__doc__
> >
> > £¨Ô´Îļþ£ºcode/func_doc.py£©
> > Êä³ö
> >
> > $ python func_doc.py
> > 5 is maximum
> > Prints the maximum of two numbers.
> >
> >         The two values must be integers.
> >
> > µ«ÊÇÎÒÔËÐÐʱ£¬È´µÃµ½ÈçÏ»ØÏÔ£º
> >
> > 5 is maximum
> >
> > Traceback (most recent call last):
> >   File "D:\Python25\func_doc.py", line 16, in 
> >     print printMax._doc_
> > AttributeError: 'function' object has no attribute '_doc_'
> >
> > googleÁËһϣ¬Ã»ÓÐÕÒµ½´ð°¸£¬ms ÕâλÐÖµÜ<http://mailman.linuxchix.org/pipermail/techtalk/2004-April/018394.html>
> > Ò²ºÍÎÒÊÇͬһ¸öÎÊÌâ
> >
> > Çë´ïÈ˴ͽ̣¬thx
> >
> > ------------------------------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> ±±Æû¸£ÌïÆû³µ¹¤³ÌÑо¿Ôº³ËÓóµËù
>                        Öì¼Ò·¢
>                    010-59912466
>                     15980725004
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070214/6f3bddb0/attachment.htm 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号