Skip to content

Commit 0e65b48

Browse files
committed
Merge pull request yasoob#113 from ssundarraj/master
Add idomatic way to retrieve multiple return values.
2 parents dc63b2a + 21be0dd commit 0e65b48

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

global_&_return.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,10 @@ Or by more common convention:
119119
age = 30
120120
return name, age
121121
122+
profile_name, profile_age = profile()
123+
print(profile_name)
124+
# Output: Danny
125+
print(profile_age)
126+
# Output: 30
127+
122128
This is a better way to do it along with returning ``lists`` and ``dicts``. Don't use ``global`` keyword unless you know what you are doing. ``global`` might be a better option in a few cases but is not in most of them.

0 commit comments

Comments
 (0)