Pythonic code: Tip #3 Merging dictionaries cleanly in Python

preview_player
Показать описание
Dictionaries play an absolutely central role in Python. In fact, the previous two tips both touched on dictionaries in one way or another.

This tip is about merging dictionaries.

This data may appear in three dictionaries. One for the route, one for the query string, and one for the form data. As the web developer, answer the question where do I get the ID (which dictionary)? What if it's missing from one, where do I fall back to? This is not clean code.

We can fix it by merging the dictionaries into a master "submitted data" dictionary with the right priorities.

How do we do this merge? This video and related blog post will show you the options.
Рекомендации по теме
Комментарии
Автор

Thanks mate, its very good explaining.

aliince
welcome to shbcf.ru