class SearpcClient(object):
def call_remote_func_sync(self, fcall_str):
raise NotImplementedError()
class RpcClientBase(SearpcClient):
def __init__(self, ccnet_client_pool, service_name, retry_num=1,
is_remote=False, remote_peer_id='', req_pool=False):
SearpcClient.__init__(self)
self.pool = ccnet_client_pool
self.service_name = service_name
self.retry_num = retry_num
self.is_remote = is_remote
self.remote_peer_id = remote_peer_id
self.req_pool = req_pool
if self.is_remote and len(self.remote_peer_id) != 40:
raise ValueError("Invalid remote peer id")
class User(object):
is_staff = False
is_active = False
is_superuser = False
groups = []
org = None
objects = UserManager()
简单说,一个是类数据属性,一个是对象属性。
复杂说,你需要好好看看 class 部分,下面是我整理的一些资料:
https://github.com/xuelangZF/CS_Offer/blob/master/More/Python_Class.md
还可以看 Python Cookbook:
http://python3-cookbook.readthedocs.io/zh_CN/latest/chapters/p08_classes_and_objects.html
你可能还需要点 面向对象 的常识!