When you render a string with """, both newlines AND whitespaces are counted. If you want this to work without dedent, your code should look like this:
def __str__(self):
return """#{0}
{1}
{2}
""".format(self.a,self.b,self.c)
Otherwise, the tabs before {1} and {2} are in the string as well. Alternatively, you could use:
"#{0}\n{1}\n{2}\n".format(self.a,self.b,self.c)
Regarding dedent and why it's not working, note this line from the documentation:
the lines " hello" and "\thello" are considered to have no common leading whitespace.
So if you want dedent to work, you need each line to start the same, so your code should be:
return textwrap.dedent(
"""\
#{0}
{1}
{2}
""".format(self.a,self.b,self.c))
And in this case each line starts with \t, which dedent recognizes and removes.
textwrap.dedentgets rid of common leading whitespace. This means that each line must have the same whitespace in front of it. Clearly, your first line,"#{0}...does not.