Seeking advice from seasoned Python programmer
|
10-20-2017, 07:56 AM
(This post was last modified: 10-20-2017 08:16 AM by emece67.)
Post: #4
|
|||
|
|||
RE: Seeking advice from seasoned Python programmer
Happy to know it was helping.
You can also use a dictionary to store your structure, as: a = {'array':[1, 2, 3], 'scalar1':4, 'scalar2':5} # your structure b = {'scalar2':10, 'scalar1':9, 'array':[6, 7, 8]} # another one, just to remark that order is unimportant now c = [a, b] # an array containing two of them then c[1] returns {'array': [6, 7, 8], 'scalar1': 9, 'scalar2': 10}, which is b c[1]['array'] returns [6, 7, 8] which is the array in b c[1]['array'][2] returns 8, which is the last member of the array inside b. c[1]['scalar1'] returns 9, which is the 1st scalar in b. Perhaps more legible. Regards. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Seeking advice from seasoned Python programmer - Namir - 10-19-2017, 06:53 PM
RE: Seeking advice from seasoned Python programmer - emece67 - 10-19-2017, 10:29 PM
RE: Seeking advice from seasoned Python programmer - Namir - 10-20-2017, 02:29 AM
RE: Seeking advice from seasoned Python programmer - emece67 - 10-20-2017 07:56 AM
RE: Seeking advice from seasoned Python programmer - Namir - 10-20-2017, 10:35 AM
RE: Seeking advice from seasoned Python programmer - pier4r - 10-20-2017, 08:08 AM
RE: Seeking advice from seasoned Python programmer - emece67 - 10-20-2017, 05:29 PM
|
User(s) browsing this thread: 1 Guest(s)