Python dynamic attribute creation

WANG Cong xiyou.wangcong at gmail.com
Fri Jun 25 14:23:38 EDT 2010


On 06/25/10 14:31, Richard Thomas <chardster at gmail.com> wrote:

<snip>

>
> If you desperately want to limit the attribute assignments that can be
> performed on an object you can set the __slots__ attribute of its
> type. However, the Python ethos has always been to restrict as little
> as necessary to provide the tools it needs. Performing additional
> checks every time an attribute assignment is performed is completely
> unnecessary. Remember that unlike C these checks would have to be
> performed at run-time.
>

I don't care in which way I can limit this, I care why I should limit
this by default, not vice versa?

Yeah, I do understand this could be a performance issue, but comparing
it with a language design issue, _I think_ the latter thing is much more
important than the former one.

-- 
Live like a child, think like the god.
 



More information about the Python-list mailing list