[Python-Dev] Internal namespace proposal

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jul 27 09:14:27 CEST 2006


David Hopwood wrote:

>   A restricted interpreter refuses access to any object attribute or method
>   with a name beginning with '_' (by throwing a new exception type
>   'InternalAccessException'), unless the access is from a method and its
>   static target is that method's first argument variable.

What's to stop

   def my_naughty_method(self):
     self = some_protected_object
     self._a_special_attribute = some_naughty_value

> __init__ is an internal method. This is as it should be, because it should not
> be possible to call __init__ on an existing object; only to have __init__
> implicitly called when a new object is constructed.

What about calling an inherited __init__ method?
Your proposed rule would seem to disallow

   BaseClass.__init__(self, ...)

--
Greg


More information about the Python-Dev mailing list