Closed wallrj closed 10 years ago
Yep, I thought about that before.
I guess I would go two ways:
@attributes
additionally adds a convenience argument like private=False
that automagically transforms all into _attr if true since that's a rather common case.Makes sense?
2
@attributes
additionally adds a convenience argument likeprivate=False
that automagically transforms all into _attr if true since that's a rather common case.
I think this second option would be convenient, but what I meant in my original comment was that characteristic
could implement a policy of always removing leading _
when looking for keyword argument names.
@exarkun is always reminding us that there's no such thing as a private function argument, so maybe he'd approve of that policy.
I think I’ll move this into 14.0 while waiting for glyph sacrificing goats in #9.
In Twisted we try hard to limit the public API in new classes so it would be nice if
with_init
had some way to map an argument name to an alternative private attribute name.In fact it might even be enough to have a rule that argument names beginning with
_
would be stored as private attributes but supplied without the_
prefix.twisted.python.util.FancyStrMixin
has a horrible system where you can supply a tuple of (attr_name
,display_name
). I suppose you could do something like that here.Or add a new
Attribute
class with anargument_name
option...and then allow that to be supplied to the characteristic decorators...if you see what I mean.