許多蟒蛇的IDE將啓動你喜歡的模板:什麼是最好的Python庫模塊框架代碼?
print 'hello world'
這還不夠......因此,這裏是我的骨架代碼得到這個問題開始:
我的模塊骨架,短版本:
#!/usr/bin/env python
"""
Module Docstring
"""
#
## Code goes here.
#
def test():
"""Testing Docstring"""
pass
if __name__=='__main__':
test()
,並
我的模塊骨架,長的版本:
#!/usr/bin/env python
# -*- coding: ascii -*-
"""
Module Docstring
Docstrings: http://www.python.org/dev/peps/pep-0257/
"""
__author__ = 'Joe Author ([email protected])'
__copyright__ = 'Copyright (c) 2009-2010 Joe Author'
__license__ = 'New-style BSD'
__vcs_id__ = '$Id$'
__version__ = '1.2.3' #Versioning: http://www.python.org/dev/peps/pep-0386/
#
## Code goes here.
#
def test():
""" Testing Docstring"""
pass
if __name__=='__main__':
test()
注(PEP 8,UTF-8):
"""
===MODULE TYPE===
Since the vast majority of my modules are "library" types, I have constructed
this example skeleton as such. For modules that act as the main entry for
running the full application, you would make changes such as running a main()
function instead of the test() function in __main__.
===VERSIONING===
The following practice, specified in PEP 8, no longer makes sense:
__version__ = '$Revision: 1.2.3 $'
For two reasons:
(1) Distributed version control systems make it neccessary to include more
than just a revision number. E.g. author name and revision number.
(2) It's a revision number not a version number.
Instead, the __vcs_id__ variable is being adopted. This expands to, for
example:
__vcs_id__ = '$Id: example.py,v 1.1.1.1 2001/07/21 22:14:04 goodger Exp $'
===VCS DATE===
Likewise, the date variable has been removed:
__date__ = '$Date: 2009/01/02 20:19:18 $'
===CHARACTER ENCODING===
If the coding is explicitly specified, then it should be set to the default
setting of ASCII. This can be modified if necessary (rarely in practice).
Defaulting to UTF-8 can cause anomalies with editors that have poor unicode
support.
"""
替代骨架,長的版本:(代碼改編自DasIch的答案)
#!/usr/bin/env python
# -*- coding: ascii -*-
"""
package.module
~~~~~~~~~~~~~
A description which can be long and explain the complete
functionality of this module even with indented code examples.
Class/Function however should not be documented here.
:copyright: year by my name, see AUTHORS for more details
:license: license_name, see LICENSE for more details
"""
#
## Code goes here.
#
def test():
""" """
pass
if __name__=='__main__':
test()
有很多政治公衆人物的提出編碼風格建議。我是否錯過了任何重要的最佳實踐?什麼是最好的Python模塊框架代碼?
更新
給我任何類型的,你喜歡的「最佳」。告訴我們您用什麼指標來評估「最佳」。
「最好」似乎有點含糊,也許你可以澄清你的問題。 – Francesco 2010-03-05 14:19:00
我希望得到最佳基線骨架代碼的共識。否則,我會解決只知道其他人使用。 – user213060 2010-03-05 14:37:39
@ user213060:「最佳基線」。 「最好」是什麼意思?最短?最快的?簡單?大多數功能?最大?大多數文檔?最接近Django? WSGI? 「最好」是什麼意思?請用最好的定義更新你的問題。請不要對您擁有的問題添加評論。 – 2010-03-05 15:20:10