Python Forum

Full Version: How to use a returned value?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(Jan-15-2020, 02:53 PM)joe_momma Wrote: [ -> ]clear as mud?

exactly. but no, I do understand (for the most part) the gist of what everybody is saying. would it be best practice to use different names when calling/re-using the returned values, does it matter?
Quote:would it be best practice to use different names when calling/re-using the returned values, does it matter?

It depends. Often it's hard to find different names.

If you want to understand this:
msg, destPhone, caseNum, timeStamp, sender= pullData()
Then you should read the pep-3132 (Extended Iterable Unpacking).
A good tutorial about iterable unpacking is here: https://realpython.com/lessons/tuple-ass...unpacking/
(Jan-15-2020, 03:23 PM)DeaD_EyE Wrote: [ -> ]Then you should read the pep-3132 (Extended Iterable Unpacking).

PEP-s are (usually) good reads. Me likes unpacking in for-loop (especially if one wants to have mutable list as result):

>>> for item in [(1, 2, 3), (10, 11, 12)]: 
...     print(item[1:]) 
...                                                                                                                                        
(2, 3)                                         # slices are tuples
(11, 12)
>>> for first, *rest in [(1, 2, 3), (10, 11, 12)]: 
...     print(rest)
...
[2, 3]                                         # lists
[11, 12]
Pages: 1 2