stylistic question -- optional return value
dougfort at dougfort.net
Wed Aug 28 17:58:27 EDT 2002
On Wed, 28 August 2002, Andrew Koenig wrote:
> Suppose I have a function that sometimes returns one value and sometimes
> returns two. What's the cleanest way to define such an interface?
> For the sake of this discussion, I'll use x to refer to the value that
> is always returned and y to refer to the optional value.
How about this:
result = Result();
result.x = 42
result.y = "aha!"
Doug Fort <dougfort at dougfort.net>
More information about the Python-list