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?
Beause of the comma here:
self.aa = aa,
This is the syntax for a tuple containing one element .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With