Ignoring return values in C
The common way is to just call foo(); without casting into (void). He who has never ignored printf()‘s return value, cast the first stone.
The common way is to just call foo(); without casting into (void). He who has never ignored printf()‘s return value, cast the first stone.
Like you said, return None is (almost) never needed. But you should consider that the intention of your code is much clearer with an explicit return None. Remember: a piece of code also needs to be readable by human-beings, and being explicit usually helps.
Return the string. I think the better abstraction is worth it. Until you can measure a meaningful performance difference, I’d argue that it’s a micro-optimization that only exists in your imagination. It took many years to get a good string abstraction into C++. I don’t believe that Bjarne Stroustroup, so famous for his conservative “only … Read more
If you want your script to return values, just do return [1,2,3] from a function wrapping your code but then you’d have to import your script from another script to even have any use for that information: Return values (from a wrapping-function) (again, this would have to be run by a separate Python script and … Read more
sys.exit(myString) doesn’t mean “return this string”. If you pass a string to sys.exit, sys.exit will consider that string to be an error message, and it will write that string to stderr. The closest concept to a return value for an entire program is its exit status, which must be an integer. If you want to … Read more
In my experience, there is no standard way how C returns a structure. To be able to pass a struct, the compiler usually (invisibly to the user) passes a pointer to the struct, to which the function can copy the contents. How this pointer is passed (first or last on stack) is implementation dependent. Some … Read more
You need to use a sentinel to detect that a default value was not set: sentinel = object() def func(someparam, default=sentinel): if default is not sentinel: print(“You passed in something else!”) This works because an instance of object() will always have it’s own memory id and thus is will only return True if the exact … Read more
You need to explicitly make it a tuple (see the official tutorial): def returns_tuple_of_one(a): return (a, )
OK. So, I did a little more investigating. Seems this is possible. I was able to emit a signal, and receive value from the slot the signal was connected to. But, the problem was that it only returned the last return value from the multiple connected slots: Here’s a simple class definition (main.cpp): #include <QObject> … Read more
This feature was added to Eclipse version 4.7 M2 under Eclipse bug 40912. To use it: step over the return statement (using “Step Over” or “Step Return”) now the first line in the variable view will show the result of the return statement, as “[statement xxx] returned: “ See Eclipse Project Oxygen (4.7) M2 – … Read more