0

I was wondering if there is an elegant way to initialize multiple class variables in one line. Consider the following class:

class Myclass():
    def __init__(self, a, b, c, d, e, f):
        self.a = b
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

I know i could do the following but with longer variable names this format loses readability.

class Myclass():
    def __init__(self, a, b, c, d, e, f):
        self.a, self.b, self.c, self.d, self.e, self.f = a, b, c, d, e, f

Is there a different way to create class variables with the corresponding name for all arguments to in one line?

martineau
  • 119,623
  • 25
  • 170
  • 301
mtosch
  • 351
  • 4
  • 18

0 Answers0