On Wed, 20 Feb 2002, Gordon McMillan wrote: > On 20 Feb 2002 at 8:30, Kevin Jacobs wrote: > > Attributes currently have a flat namespace, > > Instance attributes do, but that's a tautology. Yes, though one implication of the new slots mechanism in Python 2.2 is that we now have have non-flat per-instance namespaces for slots. i.e., we would have per-instance slots that would hide other per-instance slots of the same name from ancestor classes: class Base(object): __slots__ = ['foo'] def __init__(self): self.foo = 1 # which slot this sets depends on type(self) # if type(self) == Base, then the slot is # described by Base.foo. # else if type(self) == Derived, then the # slot is described by Derived.foo class Derived(Base): __slots__ = ['foo'] def __init__(self): Base.__init__(self) self.foo = 2 # this is NOT the same foo as in Base o = Derived() print o.foo > 2 o.__class__.__base__.foo = 3 print o.foo > 2 print o.__class__.__base__.foo > 3 So slots, as currently implemented, do not act like attributes, and this whole discussion revolves around whether they should or should not. Regards, -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: jacobs@theopalgroup.com Fax: (216) 986-0714 WWW: http://www.theopalgroup.com
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4