Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60238
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Help me to print to screen as well as log |
| Date | 2013-11-22 15:38 +0000 |
| References | <08d39aeb-cc25-4a80-b42e-fd8eac9a9d1a@googlegroups.com> <528f66ec$0$29992$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3046.1385134756.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help me to print to screen as well as log Himanshu Garg <hgarg.india@gmail.com> - 2013-11-22 05:51 -0800
Re: Help me to print to screen as well as log Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-22 14:15 +0000
Re: Help me to print to screen as well as log Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-22 15:38 +0000
Re: Help me to print to screen as well as log Peter Otten <__peter__@web.de> - 2013-11-22 15:26 +0100
Re: Help me to print to screen as well as log Himanshu Garg <hgarg.india@gmail.com> - 2013-11-23 05:11 -0800
Re: Help me to print to screen as well as log Dave Angel <davea@davea.name> - 2013-11-23 18:02 -0500
Re: Help me to print to screen as well as log Miki Tebeka <miki.tebeka@gmail.com> - 2013-11-23 16:23 -0800
Re: Help me to print to screen as well as log Himanshu Garg <hgarg.india@gmail.com> - 2013-11-23 23:00 -0800
csiph-web