Question: please do : class phone plan error * Don't import anything, and you can use all built-ins/methods that are otherwise available. * adding definitions: You


please do : class phone plan error
* Don't import anything, and you can use all built-ins/methods that are otherwise available. * adding definitions: You may add additional methods and functions in support of your solution. * displaying things: _str__and_ _repr_are used by many other places in Python to get a string representation of the object. Specifically, str() calls__str_, and repr() calls_repr__, on any objects they receive as arguments. _str__often generates a human-centric representation, appropriate for a human reading what is present.__repr_often generates a Python-centric representation. The goal of_repr__is actually to have a string that could be evaluated to re-generate an identical object. In general, we would quite prefer it to look like a valid constructor call, if possible. Ultimately, we can have the same representation in str _ and repr_ if we'd like; in fact, when we didn't explicitly describe two different string representations for_str__and__repr_ to return, we can define one in terms of the other, like this def _repr_(self): return str(self) Just remember the original intent of-st-vs-rep-. It's good practice to define-init- and_repr_immediately before writing any extra methods in a Python class at a minimum, and perhaps also eq_as well. str class CallError (Exception): Be sure to include the (Exception) portion above in your class declaration, so that this is an extension of the Exception class (with all the exception properties that implies: it can be raised) . definit_(self, msg): create/initialize instance variable for msg . def _str_(self): create/return a string based on msg as in this example "CallError : "negative_call-length :..-5" #msg== "negative_call_Length: 5" def __repr__(self): create/return a string based on msg as in this example "CallError('negative_call-length...-5')" #msg== "negative,call_Length :..-5" class PhonePlanError (Exception): Be sure to include the (Exception) portion above in your class declaration. definit (self, msg): create/initialize instance variable for msg. def-str-(self): create/return a string based on msg as in this example "PhonePlanError-duplicated-line_to_add" #msg== "duplicated .Line_te_add" . def __repr__(self): create/return a string based on msg as in this example "PhonePlanError('duplicated-line_to_add')" #msg.. "duplicatedLine_te_add
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
