I split up my class constructor by letting it call multiple functions, like this:
class Wizard:
def __init__(self, argv):
self.parse_arguments(ar
If you are using Python 3, you can try
class Wizard:
def __init__(self, argv):
self.name: str = str()
self.magic_ability: str = str()
self.parse_arguments(argv)
self.wave_wand() # declaration omitted
def parse_arguments(self, argv):
if self.has_correct_argument_count(argv):
self.name = argv[0]
self.magic_ability = argv[1]
else:
raise InvalidArgumentsException() # declaration omitted
# ... irrelevant functions omitted
Although not as pythonic as the accepted answer, but it should get away the Pylint alert.
And if you don't concern about type and don't want to create a new object with object()
use:
class Wizard:
def __init__(self, argv):
self.name = type(None)()
# ...
As None
will cause type not match error.