1

Example

PatientDir = []

class Patient_Data(object):
    def __init__(self,first_name,last_name,SSN,more,PatientDir):
        self.fn = first_name
        self.ln = last_name
        self.ssn = SSN
        self.more = more
        self.pd = PatientDir
        print("Patient Created with credentials: ",self.fn,",",self.ln)
    def update(self):
        PatientDir.append(self.pd)

    def getit(self):
        print("First Name: ",self.fn)
        print("Last NameL ",self.ln)
        print("SSN: ",self.ssn)
        print("more fields:,",self.more)

patient00000005 = Patient_Data("Julie","Roberton",123121234,
                               "More fields will be here",PatientDir)
patient00000048 = Patient_Data("Andrew","Johnson",987989876,
                               "More fields will be here",PatientDir)

Now I was curious if I could save the two patients, in a list, then i wanted to see a dictionary just to see how it works. I want to see if I could access the data through the list or dictionary, when I assigned them to the list

print(PatientDir)
[[...], [...]] 

, when I try to print the first position,

PatientDir[1]  
[[...], [...]] 

when I try to search in google I get no results. So I can't find the next step if there is a step, if you can do this? I like to try to figure things out myself but I can't find results... So what does it mean? How would I extract the information if I can? Lastly I of course would not make a program without encryption with medical data, or other sensitive data, just trying this out.

Martelmungo
  • 42
  • 1
  • 8

1 Answers1

1

The ... in the question is an infinitely recursive list. It is not an instance of an Ellipsis object, this can be tested l = []; l.append(l); l == [[...]] will give False.
The second is an Ellipsis object in a double list.
(Credits @Patrick Haugh in the comments)

python Ellipsis:

Ellipsis
The same as .... Special value used mostly in conjunction with extended slicing syntax for user-defined container data types.

This stack overflow question explains what it does.

Its interpretation is purely up to whatever implements the getitem function and sees Ellipsis objects there, but its main (and intended) use is in the numeric python extension, which adds a multidimensional array type. Since there are more than one dimensions, slicing becomes more complex than just a start and stop index; it is useful to be able to slice in multiple dimensions as well. E.g., given a 4x4 array, the top left area would be defined by the slice [:2,:2]

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
  • Your answer is wrong. The `...` in the question is not an instance of an `Ellipsis` object. You can test this your self `l = []; l.append(l); l == [[...]]` will give you `False`. The second is an `Ellipsis` object in a double list, the first is an infinitely recursive list – Patrick Haugh Oct 27 '17 at 03:26
  • Thank you @Patrick, I did not know. – Reblochon Masque Oct 27 '17 at 03:35