Merging dictionaries (|, **)
Në shqip: Bashkimi i fjalorëve
ShpjegimiSQ
Dy fjalorë i bashkon me a | b (Python 3.9+) ose {**a, **b}; çelësat e b-së fitojnë kur përsëriten. Me a |= b ose a.update(b) e ndryshon direkt a-në.
EnglishEN
You merge two dictionaries with a | b (Python 3.9+) or {**a, **b}; b's keys win when repeated. With a |= b or a.update(b) you change a directly.
Si ta mendosh
Si t'i bashkosh dy lista kontaktesh: numri më i ri zëvendëson të vjetrin.
Lexoje në anglisht
Like merging two contact lists: the newer number replaces the old one.
Shembull kodipython
baza = {"gjuha": "sq", "tema": "light"}
perdoruesi = {"tema": "dark"}
konfig = baza | perdoruesi # {'gjuha': 'sq', 'tema': 'dark'}