47 lines
1.5 KiB
Plaintext
47 lines
1.5 KiB
Plaintext
From: geek+ at cmu.edu (geek+ at cmu.edu)
|
|
Date: 5 Apr 1999 11:42:04 -0400
|
|
Subject: Subattributes of classes
|
|
Message-ID: <emacs-smtp-4003-14088-55756-878173@export.andrew.cmu.edu>
|
|
Content-Length: 1225
|
|
X-UID: 763
|
|
|
|
Then <aa8vb at vislab.epa.gov> spoke up and said:
|
|
>
|
|
> class A:
|
|
> def __init__( self ):
|
|
> self.attr = 123
|
|
> self.attr.subattr = 456 # <--------- Error!
|
|
>
|
|
> a = A()
|
|
>
|
|
>
|
|
> This generates an error as I would have expected.
|
|
>
|
|
> However, I see the same syntax in:
|
|
> demos/tkinter/matt/canvas-with-scrollbars.py
|
|
|
|
because in the demo you pointed to, they are setting sub-attributes of
|
|
an integer. The object 123 is immutable. Do it this way:
|
|
|
|
class foo: pass
|
|
f = foo()
|
|
f.bar = foo()
|
|
f.bar.baz = 123
|
|
|
|
--
|
|
=====================================================================
|
|
| JAVA must have been developed in the wilds of West Virginia. |
|
|
| After all, why else would it support only single inheritance?? |
|
|
=====================================================================
|
|
| Finger geek at cmu.edu for my public key. |
|
|
=====================================================================
|
|
-------------- next part --------------
|
|
A non-text attachment was scrubbed...
|
|
Name: not available
|
|
Type: application/pgp-signature
|
|
Size: 266 bytes
|
|
Desc: not available
|
|
URL: <http://mail.python.org/pipermail/python-list/attachments/19990405/ba7fa072/attachment.sig>
|
|
|
|
|