Note the code division multi-line and single-line comments, with a single line comment #
, the comment may be multi-line three pairs of double quotes“”” “””
Here for everyone to see the comment section of the standard code, ignore the meaning of the code
def subclass_exception(name, parents, module, attached_to=None): """ Create exception subclass. Used by ModelBase below. If 'attached_to' is supplied, the exception will be created in a way that allows it to be pickled, assuming the returned exception class will be added as an attribute to the 'attached_to' class. """ class_dict = {'__module__': module} if attached_to is not None: def __reduce__(self): # Exceptions are special - they've got state that isn't # in self.__dict__. We assume it is all in self.args. return (unpickle_inner_exception, (attached_to, name), self.args) def __setstate__(self, args): self.args = args class_dict['__reduce__'] = __reduce__ class_dict['__setstate__'] = __setstate__ return type(name, parents, class_dict)
Code comments principles:
- Not all the code to add comments, or just need to find it difficult to understand the important part to add a comment to their own
- Comments can either Chinese or English, but never Pinyin oh
- Not only to give their comments to see, but also to others, so please write carefully