python __init__ argument becomes a tuple

init, python

Solution

Beause of the comma here:

self.aa = aa,

This is the syntax for a tuple containing one element .

Problem

Code: ``` class MyClass: def __init__(self, aa ): print('aa='+str(aa)+' of type '+str(type(aa))) self.aa = aa, print('self.aa='+str(self.aa)+' of type '+str(type(self.aa))) DEBUG = MyClass(aa = 'DEBUG') ``` Output: ``` aa=DEBUG of type <type 'str'> self.aa=('DEBUG',) of type <type 'tuple'> ``` Why does `self.aa` become a tuple and not a string?

Original source