Michele De Stefano's C++ Utilities
tuple_usage.pycmd
1 // tuple_usage.pycmd
2 //
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
4 //
5 // Distributed under the MIT License (See accompanying file LICENSE)
6 
7 
8 /**
9  * \example tuple_usage.pycmd
10  *
11  * Shows the usage of the tuple_usage extension from the Python prompt.
12  */
13 
14 mds_utils::python::Tuple usage example from the Python prompt:
15 
16 
17 >>> import tuple_usage as tu
18 >>> t = tu.create_tuple([11,22,'tt',('a',7,0.9)])
19 Built tuple length: 4
20 >>> t
21 (11, 22, 'tt', ('a', 7, 0.9))
22 >>> t2 = tu.create_from_fusion()
23 >>> t2
24 (1, 2.2, 'aaa')
25 >>> t4 = tu.create_from_seq(t2)
26 >>> t4
27 (1, 2.2, 'aaa')
28 >>> t5 = tu.create_from_seq2(t4)
29 >>> t5
30 (1, 2.2, 'aaa')
31 >>> tu.access_element(t,1)
32 22
33 >>> tu.access_element(t,-1)
34 ('a', 7, 0.9)
35 >>> tu.access_element(t,-2)
36 'tt'
37 >>> tu.set_element(t,2,0)
38 Traceback (most recent call last):
39  File "<stdin>", line 1, in <module>
40 RuntimeError: Cannot assign to element 2
41 >>>