All Questions
Tagged with python-attrs python-2.7
4
questions
1
vote
1
answer
2k
views
Using attr module and metaclasses in Python
I am trying to use the attr package to simply create a metaclass with attributes and methods to use in a further class definition in Python 3. I want to use the attrs package since I have a lot of ...
1
vote
3
answers
1k
views
Is it possible to self-reference type in Python attr
I am looking to do something like this:
@attr.s
class A(object):
a_dict = attr.ib(factory=Dict, type=Dict[str, A], validator=optional(instance_of(Dict)))
It is possible to type it just as type=...
2
votes
1
answer
8k
views
How to use attr.validators.optional
As per the attrs documentation, optional attributes should be declared as follow:
>>> @attr.s
... class C(object):
... x = attr.ib(validator=attr.validators.optional(attr.validators....
3
votes
5
answers
1k
views
How To Deduce Or Subtype Named Tuple From Another Named Tuple?
Preface
I was wondering how to conceptualize data classes in a pythonic way.
Specifically I’m talking about DTO (Data Transfer Object.)
I found a good answer in @jeff-oneill question “Using Python ...