hai capito perfettamente,
tra l' altro se seguo il consiglio di christian ottengo
bc@hal9000:~/stimuli$ python super.py
MRO: ['B', 'A', 'object']
__init__ class B: (('Y', 'Y', 'Z'), {1: 'A', 2: 'B', 3: 'C'}) {}
__init__ class A: (('Y', 'Y', 'Z'), {1: 'A', 2: 'B', 3: 'C'}) {}
super class B: (('Y', 'Y', 'Z'), {1: 'A', 2: 'B', 3: 'C'}) {}
class: B
kwargs : {}sono a dir poco confuso 2016-02-17 20:57 GMT+01:00 Francesco Pischedda <[email protected]>: > > 2016-02-17 19:59 GMT+01:00 Giuseppe Costanzi <[email protected]>: >> >> args = ('Y','Y','Z') >> kwargs = {1:"A", 2:"B", 3:"C"} >> >> foo = B(args, kwargs) > > > ok questo è praticamente un check della mia comprensione di questo > meccanismo di python: > > nella chiama al costruttore di B stai passando due argomenti posizionali > cioè args e kwargs che sono rispettivamente una tupla e un dict e il > __init__ di B ha un primo parametro posizionale chiamato arg (che cattura la > prima tupla) mentre mi pare di capire che tu volessi fare una cosa del tipo: > > foo = B(*args, **kwargs) > > cioè espandere la tupla args in parametri posizionali e il dict kwargs in > parametri chiave valore, ho capito male? > > > -- > "Unix IS user friendly. It's just selective about who its friend are" > > "Nevertheless I still think it’s a bad idea to make things harder for > ourselves if we can avoid it." > > "C is quirky, flawed, and an enormous success." > -- Dennis Ritchie > > "Shipping is a feature. A really important feature. Your product must have > it." > > "La gatta frettolosa ha fatto i gattini ciechi" > > > _______________________________________________ > Python mailing list > [email protected] > http://lists.python.it/mailman/listinfo/python > _______________________________________________ Python mailing list [email protected] http://lists.python.it/mailman/listinfo/python
