Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'output': 0.05; 'skip:` 10': 0.07; 'sys': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rewrite': 0.09; 'python': 0.11; 'def': 0.12; 'code?': 0.16; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subclass': 0.16; 'subject:make': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'subject:) ': 0.29; 'subject:list': 0.30; 'code': 0.31; 'class': 0.32; 'table': 0.34; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'display': 0.35; 'method': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:x 10': 0.40; 'how': 0.40; 'fulfill': 0.68; 'grow': 0.77 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: how to make return(self.res) not to output the content of list ? Date: Thu, 25 Sep 2014 08:44:39 +0200 Organization: None References: <5422CD52.8060501@gmail.com> <54235DA6.7060702@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd92bc.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411627499 news.xs4all.nl 2978 [2001:888:2000:d::a6]:33450 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78329 luofeiyu wrote: > `sys.displayhook = lambda obj: None ` will block everything to be > displayed on the interactive python console . > > i rewrite my code as the following : > > import sqlite3,os,jinja2 > db = r'data.sqlite' > con = sqlite3.connect(db) > cur = con.cursor() > > class status(): > def __init__(): > import sys > sys.displayhook=mydisplay > > def mydisplay(x): > if (x is not the result of an method grow of class status ) : x > #how to do in python code? else : pass > > def grow(self): > self.res= a data ananlyse process > return(self.res) > > def display(self): > #to display it in the html table > > > > how to fulfill the mydisplay function in python code to make x.grow() in > the following not to output the list of self.res?? > > > import analyse > x=analyse.status() > x.grow() Have grow() return a list subclass with the empty string as its repr(): >>> class GrowMethodResult(list): ... def __repr__(self): return "" ... >>> def grow(): ... return GrowMethodResult([1,2,3]) ... >>> grow() >>>