How to test if one dict is subset of another?

Jay Tee jeff.templon at gmail.com
Tue Feb 20 12:33:51 EST 2007


Hi

your post had the following construct:

>     for j in (index['user']['jeff'] & index['state']['running']):
>         do_something()

but

Python 2.3.4 (#1, Oct 11 2006, 06:18:43)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l1= [3, 4, 7, 2]
>>> l2 = [2, 3]
>>> l2 = [2, 3, 99]
>>> l1 & l2
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for &: 'list' and 'list'

what am I missing?

Thanks

JT




More information about the Python-list mailing list