Michele De Stefano's C++ Utilities
indexing_example.pycmd
1 // indexing_example_example.pycmd
2 //
3 // Copyright (c) 2009 - Michele De Stefano (micdestefano@users.sourceforge.net)
4 //
5 // Distributed under the MIT License (See accompanying file LICENSE)
6 
7 
8 /**
9  * \example indexing_example.pycmd
10  *
11  * Shows the usage of the indexing_example extension from the Python prompt.
12  */
13 
14 mds_utils::python::support_random_access usage example from the Python prompt:
15 
16 
17 >>> from indexing_example import *
18 >>> dc = Dummy_Container()
19 >>> dc[:]
20 [1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1]
21 >>> dc[0]
22 1.1
23 >>> dc[-1]
24 9.1
25 >>> dc[0::2]
26 [1.1, 3.1, 5.1, 7.1, 9.1]
27 >>> dc[::-1]
28 [9.1, 8.1, 7.1, 6.1, 5.1, 4.1, 3.1, 2.1, 1.1]
29 >>> dc[4]
30 5.1
31 >>> dc[2] = 111.1
32 >>> dc[:]
33 [1.1, 2.1, 111.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1]
34 >>> dc[-3] = 333.3
35 >>> dc[:]
36 [1.1, 2.1, 111.1, 4.1, 5.1, 6.1, 333.3, 8.1, 9.1]
37 >>> dc[1::2] = [199.9,299.9,399.9,499.9]
38 >>> dc[:]
39 [1.1, 199.9, 111.1, 299.9, 5.1, 399.9, 333.3, 499.9, 9.1]