Re: Hello Everyone! A simple questions!
As alex23 already indicated you created a recursive data-structure (by inserting a reference to the list into the second place of the list) and the interpreter handles this gracefully by showing [...]. In case you really want to insert the lists members into the second place you can assign a copy of the list. values = [0,1,2] values[1] = values[:] 2013/7/26 Thanatos xiao > >>> values = [0, 1, 2]>>> values[1] = values>>> values[0, [...], 2] > > why?? > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello Everyone! A simple questions!
Thanks I just surprised by three dot 2013/7/26 Florian Baumgartner > As alex23 already indicated you created a recursive data-structure (by > inserting a reference to the list into the second place of the list) and > the interpreter handles this gracefully by showing [...]. > > In case you really want to insert the lists members into the second place > you can assign a copy of the list. > > values = [0,1,2] > values[1] = values[:] > > > > > > 2013/7/26 Thanatos xiao > >> >>> values = [0, 1, 2]>>> values[1] = values>>> values[0, [...], 2] >> >> why?? >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello Everyone! A simple questions!
Thanatos xiao writes: > >>> values = [0, 1, 2]>>> values[1] = values>>> values[0, [...], 2] > > why?? Because. :-) Did you have a more specific question? What exactly are you expecting that code to do, and what is the surprise? -- \ “I was the kid next door's imaginary friend.” —Emo Philips | `\ | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello Everyone! A simple questions!
On 26/07/2013 12:15 PM, Thanatos xiao wrote: values = [0, 1, 2] values[1] = values values [0, [...], 2] why?? First, it helps if you tell us what you were expecting instead. In your example, you have a list where you have replaced the 2nd element with the list itself. The [...] indicates that it is self-referential; there is no other way for it to display itself, because the contained reference also refers to itself. >>> values[1] [0, [...], 2] >>> values[1][1] [0, [...], 2] >>> values[1][1][1][1][1][1][1][1][1] [0, [...], 2] >>> values[1][1][1][1][1][1][1][1][1] is values True -- http://mail.python.org/mailman/listinfo/python-list
Hello Everyone! A simple questions!
>>> values = [0, 1, 2]>>> values[1] = values>>> values[0, [...], 2] why?? -- http://mail.python.org/mailman/listinfo/python-list