python class behaves like dictionary-or-list-data-like
<p>In python3 console, input those:</p>

<pre><code>&gt;&gt;&gt; import sys
&gt;&gt;&gt; sys.version_info
sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
&gt;&gt;&gt; type(sys.version_info)  # this is class type
&lt;class 'sys.version_info'&gt;
&gt;&gt;&gt; sys.version_info[0:2]  # ?? But it acts like a list-data-like
(3, 4)
</code></pre>

<p>My questions are:</p>

<ol>
<li>How can a class act like dictionary-or-list-data-like? </li>
<li>May give an example to construct a class like this? </li>
<li>Is there some documentation about
this?</li>
</ol>

<p>You can achieve the same behaviour by overriding <strong>getitem</strong>() and <strong>setitem</strong>() in your class.</p>

<pre><code>    class Example:
        def __getitem__(self, index):
            return index ** 2

    &gt;&gt;&gt; X = Example()
    &gt;&gt;&gt; X[2]                                
    &gt;&gt;&gt; 4
</code></pre>

<p>You can override <strong>setitem</strong>() too in your class for achieving the setter kind of thing. </p>

python list class dictionary