i using python 2.7, , wondering if there difference between set()
, set()
(i.e. with/without capitalization).
specifically, python instructions https://docs.python.org/2/library/sets.html suggest sets should imported , initialized as:
from sets import set x = set()
i have been using command set() without importing anything, i.e.:
x = set()
just wondering if these identical, or if somehow different.
i have no deep knowledge on them - until saw question, thought identical.
now checked
>>> sets import set >>> x = set() >>> y = set() >>> len(dir(y)) 54 >>> len(dir(x)) 63
and realized have dfferences
>>> y = set(dir(y)) >>> x = set(dir(x)) >>> x-y set(['_compute_hash', '__module__', '_update', '_binary_sanity_check', '__setstate__', '__deepcopy__', '_repr', '__as_immutable__', 'union_update', '__slots__', '__copy__', '__as_temporarily_immutable__', '_data', '__getstate__']) >>> y-x set(['__rand__', '__ror__', '__rsub__', '__rxor__', 'isdisjoint'])
ofcourse doesn't give clear information on differences, shows not identical :)