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

Cameron Simpson cs at zip.com.au
Thu Sep 25 02:39:09 CEST 2014


On 25Sep2014 08:15, luofeiyu <elearn2014 at 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 at 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 at zip.com.au>

Drive Agressively  Rash Magnificently   - Nankai Leathers



More information about the Python-list mailing list