Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Erik Newsgroups: comp.lang.python Subject: Re: Accessing container's methods Date: Tue, 8 Dec 2015 22:37:46 +0000 Lines: 41 Message-ID: References: <5516674.oipO6xLiNU@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de NCmMFQtiR9zzLyZGU8i/1wcZ0bCLGfYebCqHOw9Cr9vw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'context': 0.05; '(of': 0.07; 'seemed': 0.07; 'though:': 0.07; 'python': 0.10; 'question.': 0.13; '(which,': 0.16; 'after,': 0.16; 'containers': 0.16; 'curious.': 0.16; 'description)': 0.16; 'erik': 0.16; 'fix,': 0.16; 'from:addr:python': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'snippets': 0.16; 'subject:Accessing': 0.16; 'wrote:': 0.16; 'string': 0.17; 'element': 0.18; 'expanded': 0.18; 'library': 0.20; 'posted': 0.21; 'to:2**1': 0.21; 'arguments': 0.22; 'bit': 0.23; 'wrote': 0.23; 'errors': 0.23; 'examples': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'sense': 0.26; 'question': 0.27; 'said,': 0.27; "skip:' 10": 0.28; 'container': 0.29; 'context,': 0.29; 'now?': 0.29; 'objects': 0.29; "i'm": 0.30; 'comments': 0.30; 'code': 0.30; 'supposed': 0.31; 'received:84': 0.32; 'class': 0.33; 'option.': 0.33; 'scalable': 0.33; 'list': 0.34; 'question,': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'why': 0.39; 'sure': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; "you'll": 0.61; 'thomas': 0.63; 'more': 0.63; 'soon': 0.65; 'realise': 0.66; 'shortly': 0.72; 'special': 0.73; 'attention': 0.76; 'saw': 0.77; 'responses': 0.93 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JN/GyJ+b c=1 sm=1 tr=0 a=Ypmeq7T0cKALDUsRPCToMg==:117 a=Ypmeq7T0cKALDUsRPCToMg==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=cAocOpxOISkVwG8NprUA:9 a=QEXdDO2ut3YA:10 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <5516674.oipO6xLiNU@PointedEars.de> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100175 Annoyingly, there seemed to be no responses to the original question when I wrote that and then shortly after, I saw all the others (and we all pretty much said the same thing - so I'm not sure why I was singled out for special attention ;)). On 08/12/15 19:02, Thomas 'PointedEars' Lahn wrote: > Erik wrote: > ^^^^ > Please fix, Erik #75656. Fixed(*) Thomas 'PointerEars', you have chosen to selectively quote snippets of code and comments out of context, so I think it's futile to respond to those arguments individually. The original request (if you read it) was to return a string that said, essentially, "I am element 2 of 3 in my container". You posted a "Quickhack" (which, to be fair, is an accurate description) which is incomplete, has errors and makes no sense in the context of the original question. We all know we can create a list in Python (of parent objects or whatever), but I think that if you expanded on that class a bit more (methods for the containers to update the contained objects on just what their index/key is etc) that you'll soon realise it's not a scalable option. Also, WRT the original question, what is the method supposed to return now? "I am element 0 of 3 in container , key 'bar' of ('bar', 'foo', 'spam') in container "? Just curious. I'm interested in this response though: >> Generally, an object should not need to know which container it's in > > NAK. All kinds of objects already "know" which container they are in. Please elucidate. Examples from the standard library would be interesting. E. (*) In the sense that it's not going to change ;)