Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'heavily': 0.04; 'caller': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'python.': 0.11; 'stack': 0.13; 'subject:python': 0.14; 'weird': 0.15; 'people:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'twin': 0.16; 'wrote:': 0.16; 'pointer': 0.18; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'function': 0.28; 'print': 0.30; 'creating': 0.30; 'returned': 0.32; 'structure': 0.34; 'item': 0.35; 'structures': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:org': 0.37; 'data': 0.39; 'to:addr:python.org': 0.40; 'provide': 0.61; 'received:194': 0.61; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'more': 0.63; 'hear': 0.64; 'within': 0.64; 'our': 0.64; 'habit': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: jmp Subject: Re: Idiosyncratic python Date: Thu, 24 Sep 2015 16:07:13 +0200 References: <560391ea$0$2885$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: paris.sequans.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: 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: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443103660 news.xs4all.nl 23855 [2001:888:2000:d::a6]:50076 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97075 On 09/24/2015 02:50 PM, paul.hermeneutic@gmail.com wrote: > > A lot of our in base weird python comes from heavily C-wired people: > > > > The classic > > for i in range(len(alist)): > > print alist[i] > > > > with its twin brother > > > > i=0 > > while i < len(alist): > > print alist[i] > > i += 1 > > > > And the even more annoying > > > > result = Result() > > getResult(result) > > > > JM > > Please follow up with good ways to write these. I hear that creating one > really good way is a Python maxim. for item in alist: print item and result = getResult() For the later, the original weird form come from a C habit to allocate returned structures within the caller and provide a pointer to it so the function can fill the data in, otherwise the structure is lost as the stack is popped out and the structure content is garbage. None of this make any sense in python. JM