1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| class Useless(object):
def __init__(self,_float=None,_int=None,other=None):
self._float=[] if _float is None else _float
self._int=[] if _int is None else _int
self.other=[] if other is None else other
def __call__(self, value=None):
if value is None:
return self._float+self._int+self.other
else:
if type(value)==float:
self._float.append(value)
elif type(value)==int:
self._int.append(value)
else:
self.other.append(value)
def __iter__(self): return iter(self._float+self._int+self.other)
def __add__(self,other):
self(other)
return self
def __radd__(self,other):self.__add__(other)
def remove(val):
if val in self._float: self._float.remove(val)
elif val in self._int: self._int.remove(val)
elif val in self.other: self.other.remove(val) |
Partager