Overriding "__setattr__" of a module - possible?

Fuzzyman fuzzyman at gmail.com
Thu Jun 17 06:12:23 EDT 2010


On Jun 17, 10:29 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
> En Thu, 17 Jun 2010 04:52:48 -0300, Alf P. Steinbach <al... at start.no>  
> escribió:
>
> > But who would have thunk that Python *isn't dynamic enough*? :-)
>
> Yep... There are other examples too (e.g. the print statement in 2.x  
> bypasses sys.stdout.write;


What do you mean by this? The print statement in 2.x does *not* bypass
sys.stdout. It may use other methods besides write (writeln perhaps)
but you can *definitely* override sys.stdout to capture the output
from print statements.

Michael Foord


> see also a recent thread "Which objects are  
> expanded by double-star ** operator?")
>
> Most of them seem to be speed optimizations, some might be considered  
> subtle bugs. But in this case (global variable references) speed is so  
> critical than even the dict lookup is inlined; the code in ceval.c says:
>
> /* Inline the PyDict_GetItem() calls.
> WARNING: this is an extreme speed hack.
> Do not try this at home. */
>
> Python is dynamic but not so much as to make it crawl like a snail...
>
> --
> Gabriel Genellina

--
http://www.voidspace.org.uk/



More information about the Python-list mailing list