Python: Why can't I iterate over a list? Is my exception class borked? -
I have already seen this question:
But it does not help me because I want to I am looking for this to be done without the use of a feature (i.e., already executable) attribute, to repeat an attribute of error:
class SCE (Exception): "" "An error while performing SCE." "Def __init __ (self, value = none):" Message: string message or a fossil of stars. "" If there is no value: self._values = ['A normal SE error has occurred.'] Alif EASTENCE (value, ARR): self._values = [value] else: Self._values = List (value) def __iter __ (self): Returns self._values def __repr __ (self): return repr (self._values) However, in the shell I received in C: ESE: For e: print (i) traceback (most recent call final): CSE except (exclude CSE (['error one', 'error two']): File "(stdin)", in line 1, (Module) type error: IRAR () type 'list' non-itera I have returned to tor I know that by __ properties, repeat on _ and _ then e.values, but I do not want to do this because it exposes the IM to my exception class petition.
The method should return a repeating object, but you are returning a list item.
Use def __iter __ (self): To get it back (self._values)
use it. From the documentation for the object. R __
(highlighting me):
This method is called when one container requires an iterator.
This method should return a new eraser object which can be repeated on all objects in the container.
Comments
Post a Comment