Python 的文件系統

628 views
566 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
628
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Python 的文件系統

    1. 1. Python wzyang@kkbox.com
    2. 2. • docstring• pydoc• ipython• doctest• sphinx
    3. 3. docstring
    4. 4. docstring• Class Method Class Method• Class Method __doc__
    5. 5. class MyClass(): def plus(self, x): return x + 1mc = MyClass()y = mc.plus(1)
    6. 6. This is a moduleclass MyClass(): This is my Class def plus(self, x): The method pluses one. return x + 1mc = MyClass()print mc.__doc__print mc.plus.__doc__
    7. 7. This is a moduleclass MyClass(): def plus(self, x): return x + 1import sysprint sys.modules[__name__].__doc__
    8. 8. pydoc
    9. 9. $pydoc MyClass
    10. 10. $pydoc -p 8080
    11. 11. ipython.A better interactive mode. $easy_install ipython
    12. 12. doctest
    13. 13. class MyClass(): def plus(self, x): The method pluses one. >>> mc = MyClass() >>> mc.plus(1) 2 return x + 1if __name__ == __main__: import doctest doctest.testmod()
    14. 14. Sphinx$easy_install sphinx
    15. 15. $sphinx-quickstart
    16. 16. :mod:`MyClass` Module+++++++++++++++++++++This is my class..... autoclass:: MyClass.MyClass :members:
    17. 17. $make html

    ×