[Python-Dev] Consistency questions

Thomas Wouters thomas@xs4all.net
Thu, 20 Jul 2000 10:35:46 +0200

On Thu, Jul 20, 2000 at 01:51:33AM -0500, Paul Prescod wrote:

> #1. Why does can I overwrite the "standard output object" with
> assignment syntax
> sys.stdout=mystdoutobj
> But I have to add a profile function with function syntax:
> sys.setprofile( myprofilefunc )

There is a slight difference in semantics: sys.stdout is occasionally read
by a function or stmt that wants to write to stdout. Changing it doesn't
actually change something in the interpreter.

sys.setprofile(), however, has to change something in the current
threadstate. It's not something that's read from the sys module every time
it's used, but rather an accompanying variable that has to be set as well.

> #2. Why doesn't dir( obj ) return inherited methods?

Because inherited methods (and other inherited attributes) aren't stored in
an instance's __dict__.

Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!