Skip to content

Instantly share code, notes, and snippets.

@gknoy
Created August 25, 2016 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gknoy/6e884fce3edda08a1566823fec37ba70 to your computer and use it in GitHub Desktop.
Save gknoy/6e884fce3edda08a1566823fec37ba70 to your computer and use it in GitHub Desktop.
Demo renaming `attr` library helpers to less-clever names
#
# demo_attrs
#
import attr
@attr.s
class Foo(object):
x = attr.ib()
y = attr.ib()
from attr import (
s as AttributedModel,
ib as attribute,
)
@AttributedModel
class Bar(object):
x = attribute()
y = attribute()
def main():
foo = Foo(x=1, y=2)
bar = Bar(x=1, y=2)
print('foo', foo)
print('bar', bar)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment