In this video I discuss the difference between print and return in Python.

Return vs print is a common issue I see with some Python developers. I always try to follow the Python Style Guide, which is pretty much the same as the style of the C standard library, so I don’t really see a difference. For Python it seems that return is the preferred function, so there are times where it’s required, but I don’t see a real difference between the two, just a preference.

I dont really have anything to say about that.

Well, in general I think return is better. I used to be a fan of print. When I was developing a large C program I got very frustrated with return. For example, if I was done with a function I wanted to execute and the function returned, I would print a statement to the screen that said “program terminated.” The return function was a dead-end, and it just made sense to avoid it.

For a while I thought I was wrong but recently I’ve been back to print. The reason I’ve given why I think it’s better is that there are some code that can be removed from the print function. For example, if you do that the print function can be removed completely from the code that uses print. This makes the code much more readable and maintainable.

In this case, though, I think it makes the code much harder to read because it means you have to type return again. I guess they could have simply saved the return statement in a separate function, but it would have been hard to keep the code separated and cleaner.

I think that the print function is something that should be used for all sorts of things. I find that it is very easy to use and very valuable to the developer – it is good at organizing your code, making it easy to find what you need, and it is very good at what it does. I also think a lot of developers tend to think that print is just for the print statement. But it is not.

The main purpose of print is to make sure your code is readable at all times. I have found that when you start a print statement, it is very important to not start the function to print something to the screen, and that is what I find very useful about print. I find the default print function is very useful because it does not require you to run the code to get the print statement started.

Python is an interpreted programming language. So when you run print statements in Python, it has to be done at runtime. When I say interpreted, I mean that you do not have to know the code beforehand. However, in order to run the code, you do have to know the code is correct. That’s much more helpful than the print statement being just for the print statement. I also think that using return is a bad practice.

Return is a statement that terminates the execution of the script. Return means that the script has stopped executing. So the return statement is not an indication that a script is finished executing.

Leave a comment