print just writes to sys.stdout by default. def print(*args, sep=" ", end="\n", file=sys.stdout): text = sep.join(str(arg) for arg in args) file.write(text) file.write(end) That'd pretty much do the same thing. Some functions and classes in CPython (the Python you get from python.org) are implemented in a programming language called C which is what CPython is written in. That means some stuff in Python will not be implemented in Python itself. Answer from nekokattt on reddit.com
🌐
W3Schools
w3schools.com › python › ref_func_print.asp
Python print() Function
Python Examples Python Compiler ... Python Certificate Python Training ... The print() function prints the specified message to the screen, or other standard output device....
🌐
Reddit
reddit.com › r/learnprogramming › so how does print function work in python?
r/learnprogramming on Reddit: So how does Print function work in Python?
October 11, 2022 -

So I am a beginner who was learning python and the first thing I learnt was printing strings. Then later on I learnt about functions and it's only now I realised that print itself is a function. Like when we say print ('hello world') we are basically calling an already existing function and not doing anything new. I didn't realise it till now. But the question I got is what does this original print function contain? How does it work? Is it possible for me to built it from scratch by myself?

Top answer
1 of 3
11
print just writes to sys.stdout by default. def print(*args, sep=" ", end="\n", file=sys.stdout): text = sep.join(str(arg) for arg in args) file.write(text) file.write(end) That'd pretty much do the same thing. Some functions and classes in CPython (the Python you get from python.org) are implemented in a programming language called C which is what CPython is written in. That means some stuff in Python will not be implemented in Python itself.
2 of 3
9
I didn't realise it till now. But the question I got is what does this original print function contain? How does it work? Is it possible for me to built it from scratch by myself? Someone had to build Python from scratch by themselves, so yes, it's possible. You might not be able to do it in pure Python, though. If you look inside the print() function, and follow the code, eventually you'll get to a point where you need to start looking at the Python interpreter, which is likely written in C. If you follow that C code, you'll eventually get to a place where the C code makes what is called a "system call". A system call looks like a normal C function call, but the function that is being called is in the operating system kernel. On modern computers, the operating system is responsible for coordinating how different programs interact on the system. Any time a program wants to output data, it has to go through the operating system. This includes writing to files, sending data across the network, sending data to other process, and sending data to the screen. You don't need to have a deep understanding of how the operating system does this, just what system calls exist and how to use them. On Linux, the specific system call that is ultimately responsible for sending your string to the operating system is called write(). Different operating systems will have a different set of system calls, and I'm not sure what system call gets used on other operating systems.
Discussions

Why is print not a function in python? - Stack Overflow
Why is print a keyword in python and not a function? More on stackoverflow.com
🌐 stackoverflow.com
Asking for help understanding the difference between return and print in function
Hey, everybody. I started functions a few days ago in Python Crash Course. I like this chapter, I understand a function’s purpose, but I’m not understanding the differences between print and return. I also have a question about assigning a variable to a function. More on discuss.python.org
🌐 discuss.python.org
0
0
March 14, 2024
In python, how do I get a def function to print?
You need to post your code as code block so that the indentation is maintained. This is absolutely vital for Python programs as the indentation is used to denote code blocks. A code block looks like: def __init__(self, prompt, answer): self.prompt = prompt self.answer = answer More on reddit.com
🌐 r/learnprogramming
8
1
January 4, 2023
Why did python 3 change the 'print' syntax?

Python 2 accepted both :

It didn't really. Try printing two things and you'll see that the parentheses are forming a tuple, and not being interpreted as a function call.

>>> print('foo', 'bar')
('foo', 'bar')

That's very rarely what you want. It just happens to work by luck if you only have a single item because in that case the parentheses are just redundant in the same way as the ones in (4) + 2.

print was a statement in 2.x, but it's a function in 3.x. There are a number of very good reasons for this.

  • You can't use keyword arguments if it's a statement. In 3.x you can easily customize behavior with things like:

      print(a, b, c, sep=',', end='|')
      print('foo', flush=True)

    Under 2.x you have very little flexibility, and the language had to implement a really inconsistent set of syntax rules to account for customization. For example to print to a file handle other than stdout you have to use this bizarre syntax:

      print >>sys.stderr, 'foo'

    You never see anything else like that anywhere in Python. Or if you wanted to skip printing the line terminator, you had to put a trailing comma

      print a, b, c,

    Again, that just looks wrong. When print is a function, all this garbage goes away and you use standard function calling syntax that works like the rest of the language:

      print('foo', file=sys.stderr)
      print(a, b, c, end='')
  • You can't use argument splatting with a statement. In 3.x if you have a list of items that you want to print with a separator, you can do this:

      >>> items = ['foo', 'bar', 'baz']
      >>> print(*items, sep='+')
      foo+bar+baz

    Again, this is just like the previous point — there's no reason that print should be special. These are capabilities that other functions have already had forever, so why shouldn't they apply to print as well.

  • You can't override a statement. If you want to change the behavior of print, you can do that when it's a function but not when it's a statement. For example, if you want to automatically flush the stream after every output, you can do something like:

      print=functools.partial(print, flush=True)

    Now every call to print(...) acts like you wrote print(..., flush=True). Or maybe you want to turn every call to print() into a call to a logging function. The possibilities are endless, but you can't do any of this if print is a statement, because then it has its own special rules that are different than everything else in the language, and that's just absurd.

More on reddit.com
🌐 r/Python
61
219
December 16, 2014
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-output-using-print-function
Python - Print Output using print() function - GeeksforGeeks
Python print() function prints the message to the screen or any other standard output device. In this article, we will cover about print() function in Python as well as it's various operations.
Published   July 11, 2025
🌐
Mimo
mimo.org › glossary › python › print-function
Explore Python's print() function, master output customization
The print() function is the standard command for generating visible output from a Python script. Python’s print() function takes several arguments, including objects to output and various optional arguments.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-print-function
Python print() function - GeeksforGeeks
The print() function in Python displays the given values as output on the screen. It can print one or multiple objects and allows customizing separators, endings, output streams and buffer behavior.
Published   2 weeks ago
🌐
Real Python
realpython.com › python-print
Your Guide to the Python print() Function – Real Python
June 25, 2025 - In contrast, Python’s print() function always adds \n without asking, because that’s what you typically want. To disable it, you can take advantage of yet another keyword argument, end, which dictates what to end the line with. In terms of semantics, the end parameter is almost identical to the sep one that you saw earlier:
Find elsewhere
🌐
Snarky
snarky.ca › why-print-became-a-function-in-python-3
Why `print` became a function in Python 3
August 20, 2018 - In other words, with print as a function it becomes composable while as a statement it isn't. Heck, you can even override the print function by assigning to builtins.print while you can't do that with a statement.
🌐
Python Programming
pythonprogramming.net › python-tutorial-print-function-strings
Print Function and Strings
March 8, 2023 - The print function in Python is a function that outputs to your console window whatever you say you want to print out. At first blush, it might appear that the print function is rather useless for programming, but it is actually one of the most widely used functions in all of python.
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-print.html
print() and Standard Out
The Python print() function takes in python data such as ints and strings, and prints those values to standard out. To say that standard out is "text" here means a series of lines, where each line is a series of chars with a '\n' newline char marking the end of each line.
🌐
Quora
quora.com › What-is-the-print-function-in-Python-What-are-its-advantages-over-the-print-statement
What is the print() function in Python? What are its advantages over the print statement? - Quora
Answer: > What is the print() function in Python? It’s a function that takes 0 or more arguments and prints their string representations to a file (defaulting to standard output) with a separator (defaulting to a space) between them and an ...
🌐
Python Morsels
pythonmorsels.com › print-features
The power of Python's print function - Python Morsels
September 3, 2025 - Python's print function is usually one of the first built-in functions that new Pythonistas learn about, but many Python programmers don't realize how versatile the print function is.
🌐
Software Testing Help
softwaretestinghelp.com › home › python › complete guide to python print() function with examples
Complete Guide To Python print() Function With Examples
April 1, 2025 - We give one argument and a tuple having two elements ( “ car: ” and the object car ). Tuple will print their representation that is mostly used for debugging purposes. In Python3 “ print ” became a function and it needs parentheses.
🌐
Quora
quora.com › What-is-the-Python-print-function
What is the Python print function? - Quora
Answer (1 of 6): Python’s print() function is a function that tells Python to display the message in the parentheses. Let’s try this example: In this video, we would try to print the string “This is an example” https://youtu.be/zlNBZ0yIpnY But... before that, let’s break down this ...
🌐
Python.org
discuss.python.org › python help
Asking for help understanding the difference between return and print in function - Python Help - Discussions on Python.org
March 14, 2024 - Hey, everybody. I started functions a few days ago in Python Crash Course. I like this chapter, I understand a function’s purpose, but I’m not understanding the differences between print and return. I also have a questio…
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › Functions › Printvsreturn.html
12.13. 👩‍💻 Print vs. return — Foundations of Python Programming
January 4, 2023 - Printing has no effect on the ongoing execution of a program. It doesn’t assign a value to a variable. It doesn’t return a value from a function call. If you’re confused, chances are the source of your confusion is really about returned values and the evaluation of complex expressions. A function that returns a value is producing a value for use by the program, in particular for use in the part of the code where the function was invoked.
🌐
CodeChef
codechef.com › blogs › print-in-python
Python print() function (Example and Practice)
December 2, 2025 - You need to enable JavaScript to run this app
🌐
LearnPython.com
learnpython.com › blog › python-print-function
A Complete Guide to the Python print() Function | LearnPython.com
January 25, 2022 - The Python print() function is a basic one you can understand and start using very quickly. But there’s more to it than meets the eye. In this article, we explore this function in detail by explaining how all the arguments work and showing ...
🌐
Simplilearn
simplilearn.com › home › resources › software development › print in python: an overview on print() function with examples
Print in Python: An Overview on Print() Function with Examples
May 11, 2021 - The Print() function is used to print the specified message on a device’s screen or other standard output. Learn all about print in python. Start now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States