Python function returns:

Sion Arrowsmith siona at
Thu May 4 17:01:33 CEST 2006

Michael Yanowitz <m.yanowitz at> wrote:
>  In Python, there does not seem to be an easy way to have functions return
>multiple values except it can return a list such as:
>strHostname, nPortNumber, status = get_network_info (strIpAddress,
>                                                     nPortNumber)
>  Am I missing something obvious? Is there a better, or more standard way
>to return values from functions?

I'm kind of repeating what other people have said, but there
isn't a better way. Not just in Python, but in any language.
If your function is returning multiple values, why should you
have to split them into one privileged "return value" plus a
bunch of Out (or InOut) parameters? That's a historical mis-
feature of older languages, and one which more newer languages
would do well to fix.

\S -- siona at --
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump

More information about the Python-list mailing list