Help me to print to screen as well as log

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Nov 22 10:38:52 EST 2013


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




More information about the Python-list mailing list