In C/C++, it is common to write a function which returns a success or failure flag and indicates the pass-by-reference object/list is ready to use. For example,
bool get_list(List& l)
{
...
if (ready)
{
l = m_list
}
return ok
}
In python, I understand we can return more than one thing in a function but this does not look neat. What is the equivalent way to return the object/list and the boolean flag?
Edit
Thanks for the comments. I understand we should use exception in modern C++ code but you can see a lot of similar C/C++ code lying around. As mentioned in my question, I know we can return tuple in python (i.e. more than one thing -- sorry for not using the python context). I think I did not use the correct example which leads to the confusion here. For example, it can be something like if you want to return a member variable with list type when it is ready (some condition matches). Instead of returning the list and do the check outside, you can use a flag to indicate if the list is ready to use, which is more efficient.
But as per the below answers suggested, returning tuples is the way to achieve it.