What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-25 00:40:03
reset shuffed array python
import random class Solution(object): def __init__(self, nums): self.original = [x for x in nums] self.temp = nums self.indices = [x for x in range(len(nums))] def re... Add solution -
Python 2022-03-19 14:00:02
python defining the iterator protocol
class RangeTen: def __init__(self, *args): pass # optional def __iter__(self): '''Initialize the iterator.''' self.count = -1 return self def __next__(self): '''Called for each iteration. Raise StopIteration when done.''' if... Add solution -
Python 2022-03-17 07:10:05
what is composition in python
# It's when a class has a (is made-of) another class. # Example class Thing(object): def func(self): print("Function ran from class Thing().") class OtherThing(object): # Note that I don't use inheritance to get the func() fun... Add solution -
Other 2022-03-10 15:45:03
function composition python
# It's when a class has a (is made-of) another class. # Example class Thing(object): def func(self): print("Function ran from class Thing().") class OtherThing(object): # Note that I don't use inheritance to get the func() fun... Add solution