Python Forum
Unpacking a dict with * or **
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unpacking a dict with * or **
#5
(Nov-30-2023, 02:51 PM)Gribouillis Wrote: *x is not a valid Python expression, it cannot be evaluated. What would its value be? On the other hand func(*x) is a valid expression. There is no unary operator * or **.

Thank you. I originally thought it was a unary operator that would unpack x. But then that unary operator would be a function and functions return scalars or tuples, a pack not unpack of results. If not a unary operator than what? Your response made me think. It seems like * and ** are part of the language syntax and the language parser treats them like an operator in certain cases. Thank you.
Reply


Messages In This Thread
Unpacking a dict with * or ** - by msrk - Nov-30-2023, 02:40 PM
RE: Unpacking a dict with * or ** - by Gribouillis - Nov-30-2023, 02:51 PM
RE: Unpacking a dict with * or ** - by msrk - Dec-02-2023, 11:50 PM
RE: Unpacking a dict with * or ** - by deanhystad - Nov-30-2023, 05:45 PM
RE: Unpacking a dict with * or ** - by rob101 - Nov-30-2023, 05:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  iterate through the dict_values while unpacking the dictionary PeacockOpenminded 3 2,583 Jan-22-2023, 12:44 PM
Last Post: PeacockOpenminded
  Unpacking zip object Mark17 12 6,876 Mar-28-2022, 04:59 PM
Last Post: deanhystad
  unpacking list wardancer84 2 2,664 Sep-11-2021, 02:42 PM
Last Post: wardancer84
  unpacking tuple not working project_science 1 2,526 Jan-09-2021, 09:09 PM
Last Post: buran
  Unpacking a list Mark17 3 3,802 Dec-18-2020, 05:08 AM
Last Post: aajkaal
  Unpacking wheel files DavidTheGrockle 3 31,724 Dec-15-2020, 05:11 PM
Last Post: DavidTheGrockle
  Why the result of "extended iterable unpacking" with set() is unpredictable? zohanlin 2 2,923 Jun-29-2020, 10:30 AM
Last Post: zohanlin
  Unpacking nested lists yonatan776 1 2,901 Apr-14-2020, 08:50 PM
Last Post: buran
  Sort a dict in dict cherry_cherry 4 104,605 Apr-08-2020, 12:25 PM
Last Post: perfringo
  Unpacking dictionary from .xlsx as Kwargs etjkai 5 4,118 Dec-27-2019, 05:31 PM
Last Post: etjkai

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020