Skip to content

Instantly share code, notes, and snippets.

@jimbaker
Last active December 29, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbaker/7586767 to your computer and use it in GitHub Desktop.
Save jimbaker/7586767 to your computer and use it in GitHub Desktop.
Comparing methods for java.util.{List, Map, Set} with dict, list, set in Jython
>>> from java.util import List, Map, Set
>>> dir(Map)
['Entry', '__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', '__subclasshook__', '__unicode__', 'class', 'clear', 'containsKey', 'containsValue', 'empty', 'entrySet', 'equals', 'get', 'getClass', 'hashCode', 'isEmpty', 'keySet', 'notify', 'notifyAll', 'put', 'putAll', 'remove', 'size', 'toString', 'values', 'wait']
>>> dir(dict)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'setifabsent', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues']
>>> sorted(set(dir(dict)) - set(dir(Map)))
['__cmp__', '__ge__', '__gt__', '__le__', '__lt__', 'copy', 'fromkeys', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'setifabsent', 'update', 'viewitems', 'viewkeys', 'viewvalues']
>>> sorted(set(dir(list)) - set(dir(List)))
['__add__', '__delslice__', '__ge__', '__getslice__', '__gt__', '__iadd__', '__imul__', '__le__', '__lt__', '__mul__', '__radd__', '__reversed__', '__rmul__', '__setslice__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'reverse', 'sort']
>>> sorted(set(dir(set)) - set(dir(Set)))
['__and__', '__cmp__', '__ge__', '__gt__', '__iand__', '__ior__', '__isub__', '__ixor__', '__le__', '__lt__', '__or__', '__sub__', '__xor__', 'copy', 'difference', 'difference_update', 'discard', 'intersection', 'intersection_update', 'isdisjoint', 'issubset', 'issuperset', 'pop', 'symmetric_difference', 'symmetric_difference_update', 'union', 'update']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment