[Python-ideas] Write-only property [was Re: The AttributeError/__getattr__ mechanism]
Steven D'Aprano
steve at pearwood.info
Mon Nov 30 05:32:54 EST 2015
On Sun, Nov 29, 2015 at 11:31:14AM -0800, Andrew Barnert via Python-ideas wrote:
> (How would you implement a write-only property
> that makes "print(spam.eggs)" raise an AttributeError except by
> raising it in the property function?)
eggs = property(None, setter, None, "")
makes eggs a write-only property. print(spam.eggs) gives
AttributeError: unreadable attribute
--
Steve
More information about the Python-ideas
mailing list