48 lines
935 B
Plaintext
48 lines
935 B
Plaintext
From: phd at sun.med.ru (Oleg Broytmann)
|
|
Date: Mon, 5 Apr 1999 15:43:26 GMT
|
|
Subject: Subattributes of classes
|
|
In-Reply-To: <19990405104408.A807008@vislab.epa.gov>
|
|
References: <19990405104408.A807008@vislab.epa.gov>
|
|
Message-ID: <Pine.SOL2.3.96.SK.990405194204.26338F-100000@sun.med.ru>
|
|
X-UID: 1243
|
|
|
|
On Mon, 5 Apr 1999, Randall Hopper wrote:
|
|
> class A:
|
|
> def __init__( self ):
|
|
> self.attr = 123
|
|
> self.attr.subattr = 456 # <--------- Error!
|
|
>
|
|
> a = A()
|
|
>
|
|
>
|
|
> This generates an error as I would have expected.
|
|
[skipped]
|
|
> Why?
|
|
|
|
Try this:
|
|
|
|
class B:
|
|
pass
|
|
|
|
class A:
|
|
def __init__( self ):
|
|
self.attr = B()
|
|
self.attr.subattr = 456
|
|
|
|
a = A()
|
|
|
|
> Randall
|
|
>
|
|
>
|
|
>
|
|
|
|
Oleg.
|
|
----
|
|
Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/
|
|
Programmers don't die, they just GOSUB without RETURN.
|
|
|
|
|
|
|
|
|
|
|