构造python模块的约定

2024-10-03 23:27:28 发布

您现在位置:Python中文网/ 问答频道 /正文

对于python模块的内容结构是否有一个PEP或具有普遍约束力的约定? 我现在的结构是

  1. 模块篡改
  2. 元变量(uuu all,uuu author,uuu version,…)
  3. 包括
  4. 模块方法
  5. 班级

如下所示(此处没有模块方法):

"""
Generic clients

This package contains abstract, generic clients for foreign-API interaction.
Please see the client's documentation for advises for implementation. 
"""
__date__ = "16.07.2014"
__author__ = "My Name <me@company.com>"
__all__ = ['ImportClient',
           'ExportClient',
           'IEClient', 
           'CRUDClient']

from .abc import CustomerAwareConfigurableSlaveLog
from ..config import Config
import pyopenimmo as OpenImmo
from abc import abstractmethod

class ImportClient(CustomerAwareConfigurableSlaveLog):
    """
    Generic client that can import OpenImmo data
    """
    @abstractmethod
    def import_(self, openimmo):
        """
        Imports OpenImmo data from API
        """
        pass


class ExportClient(CustomerAwareConfigurableSlaveLog):
    """
    Generic client that can export OpenImmo data
    """
    @abstractmethod
    def export(self, openimmo): #@UnusedVariable
        """
        Exports OpenImmo data to API
        """
        return
<snip>

这对我来说似乎很可行,但我也希望其他人发现我的代码易于理解。你知道吗


Tags: 模块fromimportclientapifordataall