[Python-ideas] A user story concerning things knowing their own names
Ian Bicking
ianb at colorstudy.com
Mon Mar 21 06:18:48 CET 2011
On Mon, Mar 21, 2011 at 12:10 AM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:
> Guido van Rossum wrote:
>
> So, apologies if this has been brought up or rejected before, wouldn't
>> a class decorator work for you?
>>
>
> It would work, although it would be a bit less than satisfying,
> because the property wouldn't be fully self-contained. Some of
> the plumbing would still be showing, albeit less obtrusively.
>
If you forget the decorator (easy to do) the errors could be lots of ugly
"<PropertyThatMustKnowName at 0x4928394> object has no attribute 'name'" --
and you could make the error slightly better, but not much because the
PropertyThatMustKnowName doesn't get a chance to validate itself (since you
didn't use the decorator and it can't really know that).
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110321/ab1d872b/attachment.html>
More information about the Python-ideas
mailing list