Python function returns:

Sion Arrowsmith siona at chiark.greenend.org.uk
Thu May 4 11:01:33 EDT 2006


Michael Yanowitz <m.yanowitz at kearfott.com> 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,
>strHostname,
>                                                     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 chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "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