Merge pull request #12 from RazerM/dependabot/github_actions/codecov/codecov-action-4 Bump codecov/codecov-action from 3 to 4
Merge pull request #12 from RazerM/dependabot/github_actions/codecov/codecov-action-4
Bump codecov/codecov-action from 3 to 4
$ pip install represent
from represent import autorepr @autorepr class Rectangle: def __init__(self, name, color, width, height): self.name = name self.color = color self.width = width self.height = height rect = Rectangle('Timothy', 'red', 15, 4.5) print(rect)
Rectangle(name='Timothy', color='red', width=15, height=4.5)
from represent import ReprHelperMixin class ContrivedExample(ReprHelperMixin, object): def __init__(self, description, radians, shape, color, miles): self.description = description self.degrees = radians * 180 / 3.141592654 self.shape = shape self._color = color self.km = 1.60934 * miles def _repr_helper_(self, r): r.positional_from_attr('description') r.positional_with_value(self.degrees * 3.141592654 / 180) r.keyword_from_attr('shape') r.keyword_from_attr('color', '_color') r.keyword_with_value('miles', self.km / 1.60934) ce = ContrivedExample('does something', 0.345, 'square', 'red', 22) print(ce) from IPython.lib.pretty import pprint pprint(ce)
ContrivedExample('does something', 0.345, shape='square', color='red', miles=22.0) ContrivedExample('does something', 0.345, shape='square', color='red', miles=22.0)
用于生成和操作Python数据结构的表示形式
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Represent
Installation
Automatic Generation
Declarative Generation