Python helps you to avoid bad references by this mechanism. Even in C it would be better to return something legal rather than a void pointer that can be passed on to wreak havok in someone else code.
consider the following, a function called foo that we expect to return a list.
if it fails you can return a null/none or an empty list. if client code has something like:
L=foo(); for(int I=0; I < len(L); ++i) { print(L[i]); }
You can expect this to go bang when foo() fails. If you always return a legal list the app wont die when the client is careless.
If you need better error detection you can return another value denoting an error code or even use exception handling. Both of these are painless and tidy in python.
Python helps you to avoid
consider the following, a function called foo that we expect to return a list.
if it fails you can return a null/none or an empty list. if client code has something like:
L=foo(); for(int I=0; I < len(L); ++i) { print(L[i]); }
You can expect this to go bang when foo() fails. If you always return a legal list the app wont die when the client is careless.
If you need better error detection you can return another value denoting an error code or even use exception handling. Both of these are painless and tidy in python.