Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78320

Re: how to make return(self.res) not to output the content of list ?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'interpreter': 0.05; 'explicit': 0.07; 'interpreter.': 0.07; 'result,': 0.07; 'caller': 0.09; 'python': 0.11; 'def': 0.12; 'afterwards': 0.16; 'code?': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject:make': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'lets': 0.24; 'cheers,': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'subject:) ': 0.29; 'subject:list': 0.30; '(which': 0.31; 'gives': 0.31; 'that.': 0.31; 'prints': 0.31; 'trivial': 0.31; 'text': 0.33; 'subject:the': 0.34; "i'd": 0.34; 'could': 0.34; 'but': 0.35; 'received:com.au': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'received:211': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'content-disposition:inline': 0.62; 'show': 0.63
Date Thu, 25 Sep 2014 10:39:09 +1000
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: how to make return(self.res) not to output the content of list ?
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
Content-Transfer-Encoding quoted-printable
In-Reply-To <54235E8B.4040106@gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <54235E8B.4040106@gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=KMM3CZMckoUA:10 a=PdQjwTS5de8A:10 a=r5UFkecV8NkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=-GFnV9NkioqmOz_gc3oA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14338.1411606781.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411606781 news.xs4all.nl 2928 [2001:888:2000:d::a6]:33015
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78320

Show key headers only | View raw


On 25Sep2014 08:15, luofeiyu <elearn2014@gmail.com> wrote:
>You could write a separate method that just calls self.grow() and does
>not return the result, and call that method instead from the
>interactive interpreter.

luofeiyu: please take care to include the attribution line. The text above is 
from Ian Kelly, but you do not show that. Attribution is important: it both 
gives credit and also lets people know who said what.

On 25Sep2014 08:15, luofeiyu <elearn2014@gmail.com> wrote:
>how can i change your meaning into python code?

Well, I'd not do it that way. I would just make .grow() not return self.res.

Basicly, if a function returns None (which it does when it does not have an 
explicit return command), the python interpreter prints no output. So I would 
just write .grow() like this:

     def grow(self):
         self.res=  a data ananlyse process

Let the caller access self.res directly afterwards if they want to.

For Ian's suggestion, write a trivial method like this:

   def grow_but_be_silent(self):
     self.grow()

Cumbersome, but it would do what you seem to ask for.

Cheers,
Cameron Simpson <cs@zip.com.au>

Drive Agressively  Rash Magnificently   - Nankai Leathers

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to make return(self.res) not to output the content of list ? Cameron Simpson <cs@zip.com.au> - 2014-09-25 10:39 +1000

csiph-web