Path: csiph.com!au2pb.net!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.python Subject: Re: Accessing container's methods Date: Mon, 07 Dec 2015 19:46:12 +0100 Organization: PointedEars Software (PES) Lines: 23 Message-ID: <90599474.m2LfGONAbA@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1449513974 25017 eJwFwQERADEIAzBL9IAO5OzL8C/hk3SCOsFk5OYewT7pdrN24pEA32VVtehTDrPI1gAI2Q8ZzxB2 (7 Dec 2015 18:46:14 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Mon, 7 Dec 2015 18:46:14 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBwDAEBMCVqEeMwyf2H6F3bqHBRHjA1zfMslsFESW0b29ePCN98pTHqj9AWpR3hjfJHByRTuRU/URdFV0= Cancel-Lock: sha1:qlq7q/mfUU2DgV2Ku+QUCGhjAdQ= X-NNTP-Posting-Host: eJwNxsEBwCAIA8CVEEK041BK9h/B3usyuNgbTCKVouaYHC6waqPnrL/Br6Yx9Sj4EjSVzLsuJ+ERwQ== Xref: csiph.com comp.lang.python:100100 Tony van der Hoff wrote: > I have a class A, containing embedded embedded classes, which need to > access methods from A. Let the name of the "embedded class" (which is not embedded at all in your example code) be E. You could either store the information in the E instance upon or after construction, or you could pass a reference to the A instance to the E instance’s method, so that you can call the A instance’s public methods from the E instance’s methods. But consider the Law of Demeter. > I don't really want to make Actor a sub-class (is-a; it isn't) of Monty; > that would raise all sorts of other problems. It would simply be wrong. Monty (Python) is (literally) a group of Actors. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.