Python> empty XXX (XXX: dict, list, tuple, set)> {} / [] / () / set ()

Operating environment


Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 

Related http://qiita.com/7of9/items/1b78423cce1e75607195 Related http://qiita.com/7of9/items/c1958d662ec776f7df61#comment-06571c9aff0fe06914ab

About empty XXX.

http://qiita.com/7of9/items/664d0a772531692d9729 As described in, {} returns an empty dictionary.

Something similar is below.

>>> type({})
<type 'dict'>
>>> type([])
<type 'list'>
>>> type(())
<type 'tuple'>
>>> type(set())
<type 'set'>

It seems that there is no empty set only for set. Empty set literal?

You can see the attributes of set below.

>>> dir(set()) ['__and__', '__class__', '__cmp__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__iand__', '__init__', '__ior__', '__isub__', '__iter__', '__ixor__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__rand__', '__reduce__', '__reduce_ex__', '__repr__', '__ror__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__xor__', 'add', 'clear', 'copy', 'difference', 'difference_update', 'discard', 'intersection', 'intersection_update', 'isdisjoint', 'issubset', 'issuperset', 'pop', 'remove', 'symmetric_difference', 'symmetric_difference_update', 'union', 'update']

Recommended Posts

Python> empty XXX (XXX: dict, list, tuple, set)> {} / [] / () / set ()
Basic operation list of Python3 list, tuple, dictionary, set
python / Make a dict from a list.
[Python] list
python> Convert tuple to list> aList = list (pi_tuple)
Basic grammar of Python3 series (list, tuple)
[Python Iroha] Difference between List and Tuple
Python set arithmetic
Python basics: list
List type, tuple type 2
Python set arithmetic
Python> tuple> tuple unpacking
List type, tuple type
Python Dict category
Differences and commonalities between dict, list, and tuple types
Python> Comprehension / Comprehension> List comprehension
Python list manipulation
[Python] How to sort dict in list and instance in list
[Python] I want to make a nested list a tuple
Sorted list in Python
Python Exercise 2 --List Comprehension
List of python modules
Python> list> extend () or + =
Python list comprehension speed
Filter List in Python
python unittest assertXXX list
Python3 List / dictionary memo
[Memo] Python3 list sort
OpenCV3 Python API list
Python error list (Japanese)
List find in Python
Python exception class list
Initialize list with python