Q:

Python - Check if two values(strings) are both in dict

Here is dict:
a = {u'jQuery': {'categories': [u'javascript-frameworks']},
 u'Twitter Bootstrap': {'categories': [u'web-frameworks']},
 u'WooCommerce': {'categories': [u'ecommerce']},
 u'mod_ssl': {'categories': [u'web-server-extensions']},
 u'Font Awesome': {'categories': [u'font-scripts']}, 
 u'Modernizr': {'categories': [u'javascript-frameworks']},
 u'OpenSSL': {'categories': [u'web-server-extensions']},
 u'AddThis': {'categories': [u'widgets']},
 u'UNIX': {'categories': [u'operating-systems']},
 u'Gravatar': {'categories': [u'miscellaneous']},
 u'Google Font API': {'categories': [u'font-scripts']},
 u'Apache': {'categories': [u'web-servers']},
 u'WordPress': {'categories': [u'cms', u'blogs']},
 u'PHP': {'categories': [u'programming-languages']}}

I need to get True if both 'cms' and 'ecommerce' are present in whole dict.
I tried this way:
for key, value in a.items():        
    if 'cms' in value['categories'] and 'ecommerce' in value['categories']:
        print 'lala'

And:
for key, value in a.items():        
    if 'cms' and 'ecommerce' in value['categories']:
        print 'in'

With this approach it prints 'in' even if 'cms' is not present. I want it to only proceed if both strings are present.

A:

To check whether they are present in the whole dict, I would make a set of all the categories in the whole dict, and use that:
all_categories = {
    category
    for value in a.values() for category in value['categories']
}

if 'cms' in all_categories and 'ecommerce' in all_categories:
    print("Yes, that strange order of for clauses is actually correct...")

