Newbie: How to pass a dictionary to a function?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Apr 8 01:29:18 EDT 2008
En Tue, 08 Apr 2008 01:57:47 -0300, Jason Scheirer
<jason.scheirer at gmail.com> escribió:
> You want to
> return s, t
> NOT return (s, t) -- this implicitly only returns ONE item
To avoid confusing the poor newbie: No, they're absolutely the same thing,
in both cases you're returning a tuple with two items:
py> def f():
... return 1, 2
...
py> def g():
... return (1, 2)
...
py> f()
(1, 2)
py> g()
(1, 2)
py> a, b = f()
py> c, d = g()
py> c
1
py> d
2
When one says that a function like those above returns "two things",
actually it means that the function returns "a tuple with two elements",
not two separate objects.
--
Gabriel Genellina
More information about the Python-list
mailing list