with_init doesn't currently seem to support positional arguments. Maybe that's deliberate, but it's not explained in the documentation and the error message isn't particularly helpful.
I personally prefer keyword arguments, because it makes the code more readable, but sometimes the name of the variable is clue enough eg
In [13]: from characteristic import attributes
In [14]: class Foo(object):
pass
....:
In [15]: Foo = attributes(['reactor','url'])(Foo)
In [16]: dummyReactor = object()
In [17]: url = b'http://www.example.com'
In [18]: Foo(dummyReactor, url)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-18-181d7803e7c2> in <module>()
----> 1 Foo(dummyReactor, url)
/home/richard/.virtualenvs/flocker-30/lib/python2.7/site-packages/characteristic.pyc in init(self, *args, **kw)
124 v = defaults[a]
125 except KeyError:
--> 126 raise ValueError("Missing value for '{0}'.".format(a))
127 setattr(self, a, v)
128 self.__original_init__(*args, **kw)
ValueError: Missing value for 'reactor'.
So I propose adding support for positional arguments, but if not, add some better error handling and some documentation.
with_init
doesn't currently seem to support positional arguments. Maybe that's deliberate, but it's not explained in the documentation and the error message isn't particularly helpful.I personally prefer keyword arguments, because it makes the code more readable, but sometimes the name of the variable is clue enough eg
So I propose adding support for positional arguments, but if not, add some better error handling and some documentation.