[Tutor] Re: more slot stuff

Derrick 'dman' Hudson dman@dman.ddts.net
Fri, 5 Jul 2002 01:20:23 -0500


--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 04, 2002 at 07:17:08PM -0400, Arthur Siegel wrote:
| Apologies to the folks who do not share my new found interest in slots.
|=20
| Which I am starting to think of as the quark of the Python object world.
|=20
| >>> class A(object):
|  __slots__=3D("a")
| >>> class B(A):
|  __slots__=3D("b")
| >>> b=3DB()
| >>> b.__slots__
| 'b'
| >>> b.a=3D4
| In other words "a" is somehow acting as a slot for
| B instances, but is not *in* B.__slots__.
| How would one then reference, introspect, whatever
| as to what are in fact available slots for instances of B?

>>> dir( b )
['__class__', '__delattr__', '__doc__', '__getattribute__',
'__getstate__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__repr__', '__setattr__', '__slots__', '__str__',
'a', 'b']

(notice the 'a' and 'b' at the end of the list)

-D

--=20

Python is executable pseudocode. Perl is executable line noise.
=20
http://dman.ddts.net/~dman/


--1yeeQ81UyVL57Vl7
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj0lOqYACgkQO8l8XBKTpRRF1wCgmW3ntW2IbMpZE1e5YfKwvLyb
EgAAn1unQ0BaWXrliXc5+1rZSk/dcj4U
=JJ5O
-----END PGP SIGNATURE-----

--1yeeQ81UyVL57Vl7--