Muchos Python IDE le comenzar con una plantilla como:¿Cuál es el mejor código de esqueleto de módulo de biblioteca de Python?
print 'hello world'
eso no es suficiente ... Así que aquí está mi código esqueleto para obtener esta pregunta comenzó:
Mi Módulo esqueleto, versión corta:
#!/usr/bin/env python
"""
Module Docstring
"""
#
## Code goes here.
#
def test():
"""Testing Docstring"""
pass
if __name__=='__main__':
test()
y,
Mi Módulo esqueleto, Versión larga:
#!/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()
Notas (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.
"""
alternativo esqueleto, versión larga: (. Código adaptada de la respuesta de 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()
Hay un montón de PEP que presentan recomendaciones de estilo de codificación. ¿Me estoy perdiendo las mejores prácticas importantes? ¿Cuál es el mejor código de esqueleto de Python?
actualización
Muéstrame cualquier tipo de "mejor" que prefiera. Cuéntanos qué métricas usaste para calificar "lo mejor".
"mejor" parece un poco vago, tal vez podría aclarar su pregunta. – Francesco
Quiero el consenso para obtener el mejor código de esqueleto de referencia. De lo contrario, me conformaré con saber lo que todos los demás usan. – user213060
@ user213060: "para la mejor referencia". ¿Qué significa "lo mejor"? ¿Más corto? ¿Lo más rápido? ¿Más simple? La mayoría de las características? Más grande? ¿La mayoría de la documentación? El más cercano encaja con Django? WSGI? ¿Qué significa "lo mejor"? Por favor ACTUALIZA tu pregunta con una definición de mejor.No agregue comentarios a una pregunta que le pertenece. –