Python> dir ({})> dict Returns the object's attributes

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.

The following is organized by @ shiracamus's Comment.

>>> dir({}) ['__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__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues']

What type is {}?

>>> type({})
<type 'dict'>

Usage of dir. https://docs.python.jp/3/library/functions.html#dir

If there is an argument, it will try to return a list of valid attributes for that object.

The individual things seen above seem to be "attributes".

Recommended Posts

Python> dir ({})> dict Returns the object's attributes
Examine the object's class in python
Python Dict category
json.dumping None in python returns the string null
The simplest Python memo in Japan (classes and objects)
Get the result in dict format with Python psycopg2
Find the maximum Python
the zen of Python
[Python] Split the date
Get the value while specifying the default value from dict in Python
The story of rubyist struggling with python :: Dict data with pycall
2015-11-26 python> Display the function list of the module> import math> dir (math)