2012-08-19 4 views
2

code:argument de python __init__ devient un tuple

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') 

Sortie:

aa=DEBUG of type <type 'str'> 
self.aa=('DEBUG',) of type <type 'tuple'> 

Pourquoi devenir un tuple et non une chaîne?

Répondre