3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
9 * \example list_usage.pycmd
11 * Shows the usage of the list_usage extension from the Python prompt.
14 mds_utils::python::list usage example from the Python prompt:
17 >>> import list_usage as lu
18 >>> l = lu.create_list((1,1.1,2.2,'aa',('bb','h'),[1.2,'fff','t']))
21 [1, 1.1, 2.2, 'aa', ('bb', 'h'), [1.2, 'fff', 't']]
22 >>> l2 = lu.create_from_fusion()
25 >>> l3 = lu.create_from_seq((3.4,'hh',[(1,2),('o',9),['p',90]]))
27 [3.4, 'hh', [(1, 2), ('o', 9), ['p', 90]]]
28 >>> l4 = lu.create_from_seq2([1,10,'fgh'])
31 >>> lu.access_element(l,2)
33 >>> lu.access_element(l,-2)
35 >>> lu.access_element(l,-1)
37 >>> lu.access_element(l,10)
38 Traceback (most recent call last):
39 File "<stdin>", line 1, in <module>
40 RuntimeError: Cannot access element 10
41 >>> lu.set_element(l,-2,'aaa')
43 [1, 1.1, 2.2, 'aa', 'aaa', [1.2, 'fff', 't']]
44 >>> lu.set_element(l,1,'0000')
46 [1, '0000', 2.2, 'aa', 'aaa', [1.2, 'fff', 't']]
47 >>> lu.append_element(l,l2)
49 [1, '0000', 2.2, 'aa', 'aaa', [1.2, 'fff', 't'], [1, 2.2, 'aaa']]
50 >>> lu.insert_element(l,2,l3)
52 [1, '0000', [3.4, 'hh', [(1, 2), ('o', 9), ['p', 90]]], 2.2, 'aa', 'aaa', [1.2, 'fff', 't'], [1, 2.2, 'aaa']]
53 >>> lu.del_element(l,2)
55 [1, '0000', 2.2, 'aa', 'aaa', [1.2, 'fff', 't'], [1, 2.2, 'aaa']]
56 >>> lu.del_element(l,-1)
58 [1, '0000', 2.2, 'aa', 'aaa', [1.2, 'fff', 't']]
61 [1, 2.2, [1.2, 'fff', 't'], '0000', 'aa', 'aaa']
62 >>> lu.reverse_list(l)
64 ['aaa', 'aa', '0000', [1.2, 'fff', 't'], 2.2, 1]
65 >>> l5 = lu.dup_list(l)
67 ['aaa', 'aa', '0000', [1.2, 'fff', 't'], 2.2, 1]
70 [1, 'aa', '0000', [1.2, 'fff', 't'], 2.2, 1]
72 [1, 'aa', '0000', [1.2, 'fff', 't'], 2.2, 1]
73 >>> l6 = lu.dup_list2(l5)
75 [1, 'aa', '0000', [1.2, 'fff', 't'], 2.2, 1]
78 [1, 'aa', 'bbb', [1.2, 'fff', 't'], 2.2, 1]
80 [1, 'aa', 'bbb', [1.2, 'fff', 't'], 2.2, 1]
82 [1, 'aa', 'bbb', [1.2, 'fff', 't'], 2.2, 1]
83 >>> lu.append_double(l)
85 [1, 'aa', 'bbb', [1.2, 'fff', 't'], 2.2, 1, 1.1]