Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.musoftware.de!wum.musoftware.de!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'arguments,': 0.09; 'solved': 0.09; 'wrote:': 0.14; '"import': 0.16; '[snip]': 0.16; 'encounter': 0.16; 'model.': 0.16; 'received:192.168.200': 0.16; 'variable': 0.18; 'cc:2**0': 0.21; 'guess': 0.21; 'object': 0.22; 'subject:question': 0.22; 'header:In-Reply-To:1': 0.23; 'cc:addr :python-list': 0.24; 'problem': 0.28; 'nested': 0.30; 'objects.': 0.30; 'all,': 0.30; 'cc:addr:python.org': 0.30; 'considering': 0.31; 'thinking': 0.32; 'however,': 0.32; 'store': 0.34; 'received:192': 0.34; 'header:User-Agent:1': 0.34; 'using': 0.35; 'but': 0.36; 'fine.': 0.36; 'received:192.168': 0.37; 'too': 0.39; 'subject:: ': 0.39; 'sign': 0.39; 'skip:a 20': 0.40; 'your': 0.61; 'overall': 0.62; 'today': 0.71 X-IronPort-AV: E=Sophos;i="4.60,403,1291590000"; d="scan'208";a="940969" X-Virus-Scanned: amavisd-new at zimbra.sequans.com Date: Mon, 31 Jan 2011 12:15:13 +0100 From: Jean-Michel Pichavant User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) MIME-Version: 1.0 To: Gerald Britton Subject: Re: Style question: Nicknames for deeply nested objects References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "python-list \(General\)" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1296472522 news.xs4all.nl 81475 [::ffff:82.94.164.166]:35746 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56023 Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. > [snip] > > 1. You need to call this thing many times with different arguments, so > you wind up with: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) > [snip] > -- > Gerald Britton > This is not solved by style but by design. You simply don't use too much nested objects. That's a sign of something wrong in your overall object model. Since I do not encounter this problem as often as you are, I guess it is a matter of habbits. however, considering what "import a.module.that.is.quite.nested as myModule" is doing, I guess using a local variable to store your nested method is just fine. JM