Question
Explain how to redirect the output of a python script from standout(ie., monitor) on to a file ?

Answers

They are two possible ways of redirecting the output from standout to a file.
Open an output file in “write” mode and the print the contents in to that file, using sys.stdout attribute.
import sys
filename = “outputfile” sys.stdout = open() print “testing”
you can create a python script say .py file with the contents, say print “testing” and then redirect it to the output file while executing it at the command prompt.
Eg: redirect_output.py has the following code:
print “Testing”
execution: python redirect_output.py > outputfile.   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q What do i need to submit an application?
  • Q Who is the President and Prime Minister of Singapore
  • Q Constitution day?
  • Q How to divide a page into parts using jquery mobile?
  • Q In the town called Alibaug, the following facts are true: • No two inhabitants have exactly the same number of hairs. • No inhabitants has exactly 2025 hairs. • There are more inhabitants than there are hairs on the head of any one inhabitants. What is the largest possible number of the inhabitants of Alibaug?
  • Q WHAT are the commands that allow you to process sequential file? And what is their syntax?
  • Q Is blood transfusion necessary?
  • Q What are the New Job Postings from the Company or Organization, India Meteorological Department (IMD) ?
  • Q What is the administrative mechanism of SCTA's provincial bodies?
  • Q What is endpoint in mule ?
  • Q What is the significance of Bonobo ?