Provided your code already has both dictionaries as variables, it's very concise to check for this inline:
if big | small == big:
# do something
Here is a solution that also properly recurses into lists and sets contained within the dictionary. You can also use this for lists containing dicts etc...
def is_subset(subset, superset):
if isinstance(subset, dict):
return all(key in superset and is_subset(val, superset[key]) for key, val in subset.items())
if isinstance(subset, list) or isinstance(subset, set):
return all(any(is_subset(subitem, superitem) for superitem in superset) for subitem in subset)
# assume that subset is a plain value if none of the above match
return subset == superset
python
A module is a reusable, standalone script that Ansible runs on your behalf, either locally or remotely. Modules interact with your local machine, an API, or a remote system to perform specific tasks like changing a database password or spinning up a cloud instance. Each module can be used by the Ansible API, or by the ansible or ansible-playbook programs. A module provides a defined interface, accepting arguments and returning information to Ansible by printing a JSON string to stdout before exiting. Ansible ships with thousands of modules, and you can easily write your own. If you’re writing a module for local use, you can choose any programming language and follow your own rules. This tutorial illustrates how to get started developing an Ansible module in Python.
tutorial ansible pythonA completely incomplete guide to packaging a Python module and sharing it with the world on PyPI.
tutorial pythonBoto is the Amazon Web Services SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.
aws programming pythonPython's strftime directives, built automatically from the Python strftime docs.
documentation cheatsheet pythonThis post is a collection of strategies for reducing memory usage during Django migrations.
django pythonDetailed descriptions, with full methods and attributes, for each of Django's class-based generic views.
django programming pythonLooking at the number of comments per minute that reddit gets, from 1 in 2008 to more than 2300 comments per minute in 2016.
graphing reddit pythonProject starter template for Django 1.9 with production-ready configuration for Static Files, Database Settings, Gunicorn, and enhancements to Django's static file serving functionality via WhiteNoise
django programming python heroku