3

I wondered whether it is possible to print (for example a string) in Python without the print function. This can be done by a command or by some trick.

For example, in C there are printf and puts.

Can someone show me a way to print or to deny this possibility?

4
  • 5
    docs.python.org/2/tutorial/inputoutput.html Commented Jan 19, 2014 at 12:10
  • Why would you want to do this? Are you trying to make a function call instead of using the print statement? Commented Jan 19, 2014 at 12:16
  • 2
    Just like C, Python has multiple functions that default to printing to stdout. Just like C, Python documents all of those functions. Do you have an actual question, or are you just too lazy to read the tutorial and/or documentation and hoping people will telepathically guess what you want to do, read it for you, and write your code for you? Commented Jan 19, 2014 at 12:20
  • @GamesBrainia I just want to know. Commented Jan 19, 2014 at 14:48

3 Answers 3

6
sys.stdout.write("hello world\n") 
Sign up to request clarification or add additional context in comments.

1 Comment

the argument given to write here must be string.
3
import sys sys.stdout.write("hello") 

Comments

1

You can use

sys.stdout.write() 

Sometimes I find sys.stdout.write more convenient than print for printing many things to a single line, as I find the ending comma syntax of print for suppressing the newline inconvenient.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.