On 5/17/17 2:11 AM, Eric V. Smith wrote:
One use case that attrs satisfies (as does namedtuple) that I'd like to make sure we allow for in any solution is dynamically creating classes where you don't know the field names until runtime. I run in to this when reading anything with columnar metadata, like databases or CSV files. The attr.s "these" parameter solves this for me:fields = ['a', 'b', 'c'] @attr.s(these={f:attr.ib() for f in fields}) class Foo: pass
I should also have mentioned attr.make_class. _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
