Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 512 Bytes

20220917083123.md

File metadata and controls

19 lines (15 loc) · 512 Bytes

tuple unpacking with throwaway variables

I love tuple unpacking (although here we apply it to a list). Did you know you can discard one or more values with _ / *_ -> looks really elegant 😍🐍

Also note I wrote this code in the debugger, I cannot live without it these days, it makes me a lot faster.

(Pdb) fields
['FDX', 'FedEx Corporation', '158.94', '-45.93', '-22.42%']
(Pdb) symbol, name, price, *_ = fields
(Pdb) symbol
'FDX'
(Pdb) name
'FedEx Corporation'
(Pdb) price
'158.94'

#unpacking