Skip to main content
Post Closed as "Duplicate" by Antti Haapala python
deleted 19 characters in body
Source Link
zell
  • 10.4k
  • 14
  • 75
  • 138

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output. E.g, foo( ) has only one line print 'I am here'. The point is that I have no permission to change foo() which has statements that display something on my screenmay contain output statements, and I don't want to mix its output with mine.

Question:

How can I change the third line of the program above (print “Hello”), so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output. E.g, foo( ) has only one line print 'I am here'. The point is that I have no permission to change foo() which has statements that display something on my screen and I don't want to mix its output with mine.

Question:

How can I change the third line of the program above (print “Hello”), so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output. E.g, foo( ) has only one line print 'I am here'. The point is that I have no permission to change foo() which may contain output statements, and I don't want to mix its output with mine.

Question:

How can I change the third line of the program above (print “Hello”), so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

added 5 characters in body
Source Link
zell
  • 10.4k
  • 14
  • 75
  • 138

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output. E.g, foo( ) has only one line print 'I am here'. The point is that I have no permission to change foo() which has statements that display something on my screen and I don't want to mix its output with mine.

QuestionQuestion:

How can I change the third line of the program above (print “Hello”), so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output.

Question:

How can I change the third line of the program above (print “Hello”) so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output. E.g, foo( ) has only one line print 'I am here'. The point is that I have no permission to change foo() which has statements that display something on my screen and I don't want to mix its output with mine.

Question:

How can I change the third line of the program above (print “Hello”), so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.

Source Link
zell
  • 10.4k
  • 14
  • 75
  • 138

Python IO: disable standard output stream and print what we want

Say I have a python program composed of three lines.

if __name__=“__main__”: foo( ) print “Hello” 

Here, foo( ) is a third-part function that outputs things to the standard output.

Question:

How can I change the third line of the program above (print “Hello”) so that this program

1.only prints “Hello”, and

2.does not print anything from foo( )?

Thanks for your ideas.