Browse Source

Class

pull/31/head
Jure Šorn 5 years ago
parent
commit
298a026949
2 changed files with 8 additions and 8 deletions
  1. 8
      README.md
  2. 8
      index.html

8
README.md

@ -914,10 +914,10 @@ class MyCollection:
return len(self.a)
def __getitem__(self, i):
return self.a[i]
def __setitem__(self, i, value):
self.a[i] = value
def __contains__(self, value):
return value in self.a
def __setitem__(self, i, el):
self.a[i] = el
def __contains__(self, el):
return el in self.a
def __iter__(self):
for el in self.a:
yield el

8
index.html

@ -818,10 +818,10 @@ creature = Creature()
<span class="hljs-keyword">return</span> len(self.a)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__getitem__</span><span class="hljs-params">(self, i)</span>:</span>
<span class="hljs-keyword">return</span> self.a[i]
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__setitem__</span><span class="hljs-params">(self, i, value)</span>:</span>
self.a[i] = value
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__contains__</span><span class="hljs-params">(self, value)</span>:</span>
<span class="hljs-keyword">return</span> value <span class="hljs-keyword">in</span> self.a
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__setitem__</span><span class="hljs-params">(self, i, el)</span>:</span>
self.a[i] = el
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__contains__</span><span class="hljs-params">(self, el)</span>:</span>
<span class="hljs-keyword">return</span> el <span class="hljs-keyword">in</span> self.a
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__iter__</span><span class="hljs-params">(self)</span>:</span>
<span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> self.a:
<span class="hljs-keyword">yield</span> el

Loading…
Cancel
Save