Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'satisfy': 0.09; 'tismer': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'fancy': 0.16; 'garg': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:log': 0.16; 'subject:screen': 0.16; 'do,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'not,': 0.20; 'programming': 0.22; 'print': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'file.': 0.24; 'skip:" 30': 0.26; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'appear': 0.29; "d'aprano": 0.31; 'steven': 0.31; 'vertical': 0.31; 'fri,': 0.33; 'screen': 0.34; 'but': 0.35; 'should': 0.36; 'detail': 0.37; 'christian': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'space': 0.40; 'how': 0.40; 'world.': 0.61; 'save': 0.62; 'more': 0.64; 'received:89': 0.85; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Help me to print to screen as well as log Date: Fri, 22 Nov 2013 15:38:52 +0000 References: <08d39aeb-cc25-4a80-b42e-fd8eac9a9d1a@googlegroups.com> <528f66ec$0$29992$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-89-240-169-4.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: <528f66ec$0$29992$c3e8da3$5496439d@news.astraweb.com> 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385134757 news.xs4all.nl 15952 [2001:888:2000:d::a6]:36202 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60238 On 22/11/2013 14:15, Steven D'Aprano wrote: > On Fri, 22 Nov 2013 05:51:21 -0800, Himanshu Garg wrote: > >> I want that print "hello" should appear on screen as well as get saved >> in a log file. >> >> How can I accomplish this? > > print "hello" > logfile.write("hello\n") > > > Does that satisfy your need? If not, please explain in more detail what > you are trying to do, what you have already tried, and what happened when > you tried it. > Fancy wasting vertical space like that, if you use a semi-colon you can save a whole lot of it like this print "hello";logfile.write("hello\n") # :) -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence