When I add alignment to the code below
class MyClass():
def __init__(self, a = None, b = [], c = None):
self.a = a
self.b = b
self.c = c
def __str__(self):
return "a: {}, b: {}, c:{}".format(
self.a, self.b, self.c)
if __name__ == "__main__":
obj = MyClass(1, [1,2], 2)
print(obj)
in particular, to its list argument, like
class MyClass():
def __init__(self, a = None, b = [], c = None):
self.a = a
self.b = b
self.c = c
def __str__(self):
return "a: {:<3}, b: {:<3}, c:{:<3}".format(
self.a, self.b, self.c)
if __name__ == "__main__":
obj = MyClass(1, [1,2], 2)
print(obj)
I get an error:
TypeError: unsupported format string passed to list.__format__
What is the right way to do so?