[Python-Dev] Object customization (was: Arbitrary attributes on
funcs and methods)
Moshe Zadka
Moshe Zadka <mzadka@geocities.com>
Fri, 14 Apr 2000 19:46:12 +0200 (IST)
On Thu, 13 Apr 2000, Vladimir Marangozov wrote:
> >>> def this():
> ... sucks = "no"
> ...
> >>> this.sucks = "yes"
> >>>
> >>> print this.sucks
> 'yes'
>
> Why on earth 'sucks' is not the object defined in the function's namespace?
> Who made that deliberate decision? Clearly 'this' defines a new namespace,
> so it'll be also legitimate to get a NameError, or to:
>
> >>> print this.sucks
> 'no'
>
> Don't you think?
No.
>>> def this(turing_machine):
... if stops(turing_machine):
... confusing = "yes"
... else:
... confusing = "no"
...
>>> print this.confusing
<Python kills itself out of mercy>
--
Moshe Zadka <mzadka@geocities.com>.
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com