[Tutor] pointers or references to variables or sub-sets of variables query.

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Sat Jul 6 22:39:22 EDT 2019


Hi all.

 

In C, you can use pointers to reference variables, arrays, ETC. In python, I
do not recall anything specifically that refers to such a capability. What I
want to do is:

 

 

I want to create different data structures such as dictionaries which
contain specific  list elements based upon specific keys. The original data
structure could look like:

 

Data = [

  ['2019-01-19','Fred Flintstone',23],

['2019-02-01','Scooby doo', 99]

]

 

The above structure does have 100's of elements. I want to reference
specific lists within the above structure. Using the only method I know how:

 

Category = {'under-50':[data[0]], 'over-50':[data[1]]}

 

If I understand things correctly with Python. The above will copy the value
into the list within the key. Not the memory address of the nested list I am
referencing. I am using a list within the key to permit multiple references
to different nested lists from the original data structure. The end result
of the structure for the dict could look like this (using example, not real
output)

 

 

Category['under-50'] = [ List1 pointer, List22 pointer, List52 pointer]

 

 

I hope the above makes sense. How can this be done? 



More information about the Tutor mailing list