hasattr + __getattr__: I think this is Python bug

dmitrey dmitrey.kroshko at scipy.org
Tue Jul 20 11:47:00 EDT 2010


On 20 июл, 18:39, Neil Cerutti <ne... at norwich.edu> wrote:
> On 2010-07-20, dmitrey <dmitrey.kros... at scipy.org> wrote:
>
> > This doesn't stack with the following issue: sometimes user can
> > write in code "myObject.size = (some integer value)" and then
> > it will be involved in future calculations as ordinary fixed
> > value; if user doesn't supply it, but myObject.size is involved
> > in calculations, then the oofun is created to behave like
> > similar numpy.array attribute.
>
> Telling them, "Don't do that," is a good solution in Python.
>
> --
> Neil Cerutti

But this is already documented feature, and it works as intended, so
moving it into something like "myObject._size" will bring backward
incompatibility and break all FuncDesigner user API and style, where
no underlines are present, it will seem like a hack that it really
is.

Sometimes apriory knowing size value as fixed integer brings some code
speedup, also, if a user supplies the value, a check for computed
value wrt the provided size is performed each time.



More information about the Python-list mailing list