DEV Community

loading...

Discussion on: Writing functions in Python

Collapse
hanpari profile image
Pavel Morava

If you use the print statement inside something you call a function instead of the keyword return, you are creating a function with the constant return value which is None.

I wish people stopped using this demonstrations altogether because the other beginners think it is normal and encouraged practice.

Sigh, I know Python is not purely functional language, but side effects should be omitted as often as possible, and not used as educational technique.

People should use print when nobody is looking and delete all proof afterwards. 😋

Collapse
dailydevtips1 profile image
Chris Bongers Author

Fair enough, but at this point I'm learning it, and it's a valid way for me to see what it does, it's how I learn so why can't other people learn like that?

Especially if you haven't crossed the debugging part yet 😅
But valid point that a production app shouldn't have logs, same for console.logs in JS

Collapse
hanpari profile image
Pavel Morava

If you are learning Python, you should try Jupyter notebooks instead.

Or just create ipynb file if you are using VSCode or PyCharm.

Each cell will print the output for you.

Thread Thread
dailydevtips1 profile image
Chris Bongers Author

Oh cool, thanks for this information will look into that!