Python Forum
How to use a returned value? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to use a returned value? (/thread-23731.html)

Pages: 1 2


RE: How to use a returned value? - t4keheart - Jan-15-2020

(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?


RE: How to use a returned value? - DeaD_EyE - Jan-15-2020

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-assignment-packing-unpacking/


RE: How to use a returned value? - perfringo - Jan-16-2020

(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]