Post Reply 
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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Seeking advice from seasoned Python programmer - emece67 - 10-20-2017 07:56 AM



User(s) browsing this thread: 1 Guest(s)