Python function returns:

Michael Yanowitz m.yanowitz at kearfott.com
Thu May 4 08:00:47 EDT 2006


  I am still new to Python but have used it for the last 2+ months.
One thing I'm still not used to is that functions parameters can't
change as expected. For example in C, I can have
 status = get_network_info (strIpAddress, &strHostname, &nPortNumber)
  where this fictitious function returns a status, but also returns modified
values for a hostname and a port number.
  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?

Thanks in advance:
Michael Yanowitz





More information about the Python-list mailing list