python - List of tuples unpacking does not work -
I know about the *
operator but it does not seem to work. I basically want to add this list to the Tupal Combination:
sentence_list = [(['noun' '' ''], ('verb', 'kill'), ('noun 'My class sentence : class sentence (object): def __init __ (self, consider the subject)
, Word, object): self.subject = topic [1] self.verb = verb [1] self.object = object [1]
now I Test_obj And when I try to open syntax it does not seem to work:
test_obj = and Why (* Waky_suchi)
When I nose. Use with toll
:
assert_is_instance (test_obj, sentence)
I'm getting this:
typeError: __init __ () takes exactly 4 arguments (3 given)
, but when I change it:
test_obj = 'Sentence' ('noun', 'i'), ('verb', 'kill'), ('noun,' 'princess'))
T EST What am i doing wrong
Your code is just fine, provided actually has 3 elements Pass in a list:
& gt; & Gt; & Gt; Class sentence (object): ... def __init __ (self, subject, verb, object): ... self.subject = subject [1] ... self.verb = verb [1] ... self.object = Item [1] ... & gt; & Gt; & Gt; Sentence-list = [('noun', 'i'), ('verb', 'kill'), ('noun', 'princess')]> & Gt; & Gt; Sentence (* sentence_list) & lt; __ Main __. 0x10043c0d0 on sentence object & gt; & Gt; & Gt; & Gt; Del sentence_list [-1]> gt; & Gt; & Gt; Sentence (* sentence_list) traceback (most recent call final): File "& lt; stdin>", line 1, & lt; Module & gt; TypeError: __init __ () takes exactly 4 arguments (3 given)
Note the error message here; Arguments four including __ init __
self
Argos, this is your syntax
value it is on the fault, not your technique.
Comments
Post a Comment