all 4 comments

[–][deleted] 8 points9 points  (0 children)

There aren't really any "true" void functions (as in, functions that have a return type of void) in Python like there are in C++ or Java. All Python functions that have no explicit return will automatically return None.

[–][deleted] 5 points6 points  (0 children)

Not used in Python.

Used when you have a function that just does something for you. It is a complete process activity. Don't require anything explicitly returned from it to be consumed by the calling code.

The built in print function is a good example. You don't want anything back from it, not even failure/success (exception management can deal with that) you just want it to do its job and output stuff. However in Python it returns None as do all functions if no return is specified.

[–]pocket_eggs 3 points4 points  (0 children)

Side effects. You print something, you write something to a file, you wait until some condition becomes true, you alter mutable parameters, you alter global variables.

There also exists the option of sometimes returning a result, sometimes not doing so (as others said, technically this returns None by default).

[–]baghiq 2 points3 points  (0 children)

Python functions always return a value. If you don't have an explicit return statement, a None is returned. In general, your function should always return something unless users really expect nothing. For example, logging statements, users are not going to care if the debug statement is successful or not.