Python inheritance woes
<p>This is a homework question, but as you can see I've written most of the code already. :)  What I'm trying to have happen is that the <strong>Agent</strong> object inherits the methods from the <strong>Investor</strong> object, as the <strong>Agent</strong> object's methods are suppose to be basically the same. The only different is the constructors, <strong>Investor</strong> takes 6 parameters, <strong>Agent</strong> takes 7. You can see that the parameters are also basically the same.</p>

<p><strong>Investor.load</strong> and <strong>Investor.report</strong> work, for the most part, as expected. The inherited methods in <strong>Agent</strong> do not. See below.</p>

<p>My main issues:</p>

<ol>
<li>When I run <strong>report(o)</strong> on <strong>Investor</strong>, the output is slightly messed up. It has little paragraph symbols at the end of each line, rather than a carriage return. (I'm developing on linux) </li>
<li>When I run <strong>load</strong> and <strong>report</strong> on <strong>Agent</strong>, it does not populate my arrays (<strong>reports</strong> and <strong>data</strong>) as it should. Because of that, <strong>report</strong> prints nothing. How do I set up my class variables so that they work in the way I want them to?</li>
</ol>

<p>Thanks!</p>

<p><em><strong>Will re-add after turnin date.</em></strong></p>

<p>Here is how the above code <strong>SHOULD</strong> function.</p>

<pre><code>&gt;&gt;&gt; from sys import stdout as o
&gt;&gt;&gt; import datetime
&gt;&gt;&gt; from hedgefunds import *
&gt;&gt;&gt;
&gt;&gt;&gt; i = Investor('Flintstone','Fred',datetime.date(1965,12,3),'male','Mr.')
&gt;&gt;&gt;
&gt;&gt;&gt; i
Investor('Flintstone', 'Fred', datetime.date(1965, 12, 3), 'male', 'Mr.', 1)
&gt;&gt;&gt; repr(i)
"Investor('Flintstone', 'Fred', datetime.date(1965, 12, 3), 'male', 'Mr.', 1)"
&gt;&gt;&gt; i.__repr__()  # THIS CONTROLS PREVIOUS TWO LINES
"Investor('Flintstone', 'Fred', datetime.date(1965, 12, 3), 'male', 'Mr.', 1)"
&gt;&gt;&gt; eval(repr(i))  # OBJECT CAN BE RECREATED FROM ITS REPR STRING
Investor('Flintstone', 'Fred', datetime.date(1965, 12, 3), 'male', 'Mr.', 1)
&gt;&gt;&gt;
&gt;&gt;&gt; i  # NOTICE ONE ADDITIONAL BIT OF DATA WE DIDN'T SPECIFY?
Investor('Flintstone', 'Fred', datetime.date(1965, 12, 3), 'male', 'Mr.', 1)
&gt;&gt;&gt; # THE '1' AT THE END IS THE RECORD ID rid. THE REPR STRING INCLUDES ALL DATA SO YOU SEE IT.
&gt;&gt;&gt; # THE INVESTOR CLASS SHOULD ASSIGN A rid IF ONE IS NOT PASSED INTO THE CONSTRUTOR.
&gt;&gt;&gt;
&gt;&gt;&gt; print i
1, Mr. Fred Flintstone, 12/03/1965, male
&gt;&gt;&gt; i.__str__()  # THIS CONTROLS PREVIOUS LINE
'1, Mr. Fred Flintstone, 12/03/1965, male'
&gt;&gt;&gt;
&gt;&gt;&gt; # NOTE THE NAME IS NICELY PUT TOGETHER AND AND rid IS AT THE START
&gt;&gt;&gt; # NOTE datetime.date(YYYY, MM, DD) BUT WE PRINT IN  MM/DD/YYYY FORMAT
&gt;&gt;&gt;
&gt;&gt;&gt; # NOW LET'S LOOK AT OUR INVESTOR OBJECT'S ATTRIBUTES
&gt;&gt;&gt; i.last_name
'Flintstone'
&gt;&gt;&gt; i.first_name
'Fred'
&gt;&gt;&gt; i.dob
datetime.date(1965, 12, 3)
&gt;&gt;&gt; i.date_of_birth
'12/03/1965'
&gt;&gt;&gt; i.gender
'male'
&gt;&gt;&gt; i.title
'Mr.'
&gt;&gt;&gt; i.name
'Mr. Fred Flintstone'
&gt;&gt;&gt; i.rid
1 
&gt;&gt;&gt;
&gt;&gt;&gt; # BUT WE'RE GONNA NEED SOMEHWERE TO STORE MULTIPLE INVESTOR OBJECTS
&gt;&gt;&gt; # SO AS WELL AS CREATING INVESTOR OBJECTS, THE INVESTOR CLASS MUST ACT LIKE A RECORDSET
&gt;&gt;&gt;
&gt;&gt;&gt; Investor.report(o)  # o WAS SET TO STDOUT AT THE TOP OF THIS TRACE BUT COULD BE ANY FILE
&gt;&gt;&gt; Investor.add(i)  # NO RECORDS SO LET'S ADD ONE
&gt;&gt;&gt; Investor.report(o)  # NOW WE HAVE SOMETHING TO REPORT
1, Mr. Fred Flintstone, 12/03/1965, male
&gt;&gt;&gt;
&gt;&gt;&gt; Investor.add(Investor('Flintstone','Wilma',datetime.date(1968,1,15),'female','Mrs.'))
&gt;&gt;&gt; Investor.report(o)
1, Mr. Fred Flintstone, 12/03/1965, male
2, Mrs. Wilma Flintstone, 01/15/1968, female
&gt;&gt;&gt;

&gt;&gt;&gt; # WE COULD CONTINUE ADDING INVESTORS MANUALLY BUT SINCE WE'VE GOT A FILE FULL OF THEM....
&gt;&gt;&gt; Investor.load('investors.csv')
&gt;&gt;&gt; Investor.report(o)
1, Mr. Charles Creed, 12/05/1928, male
2, Miss Sheila Geller, 11/12/1962, female
3, Mr. Fred Kenobi, 07/13/1957, male
4, Miss Rachel Geller, 07/11/1968, female
5, Mr. Charles Rubble, 09/23/1940, male
6, Mrs. Leah Skywalker, 07/02/1929, female
7, Mr. Bill Balboa, 03/06/1988, male
8, Dr. Sheila Barkley, 08/26/1950, female
.
.
&gt;&gt;&gt; # YOU SHOULD SEE 120 RECORDS (OUR TWO MANUALLY ADDED RECORDS ARE GONE)
&gt;&gt;&gt;
&gt;&gt;&gt;
&gt;&gt;&gt;
&gt;&gt;&gt; # AGENTS
&gt;&gt;&gt;
&gt;&gt;&gt; a = Agent(2.1,'Rubble','Barney',datetime.date(1966,4,20),'male','Mr.')
&gt;&gt;&gt; a
Agent(2.1000000000000001, 'Rubble', 'Barney', datetime.date(1966, 4, 20), 'male', 'Mr.', 1)
&gt;&gt;&gt; repr(a)
"Agent(2.1000000000000001, 'Rubble', 'Barney', datetime.date(1966, 4, 20), 'male', 'Mr.', 1)"
&gt;&gt;&gt; eval(repr(a))
Agent(2.1000000000000001, 'Rubble', 'Barney', datetime.date(1966, 4, 20), 'male', 'Mr.', 1)
&gt;&gt;&gt; print a
1, Mr. Barney Rubble, 04/20/1966, male, 2.1
&gt;&gt;&gt; a.last_name
'Rubble'
&gt;&gt;&gt; a.first_name
'Barney'
&gt;&gt;&gt; a.dob
datetime.date(1966, 4, 20)
&gt;&gt;&gt; a.date_of_birth
'04/20/1966'
&gt;&gt;&gt; a.gender
'male'
&gt;&gt;&gt; a.title
'Mr.'
&gt;&gt;&gt; a.name
'Mr. Barney Rubble'
&gt;&gt;&gt; a.rid
1
&gt;&gt;&gt; a.commission
2.1000000000000001
&gt;&gt;&gt; Agent.add(a)
&gt;&gt;&gt; Agent.report(o)
1, Mr. Barney Rubble, 04/20/1966, male, 2.1
&gt;&gt;&gt; Agent.load('agents.csv')
&gt;&gt;&gt; Agent.report(o)
1, Mr. Barney Flintstone, 02/13/1933, male, 4.0
2, Miss Rachel Rubble, 11/21/1982, female, 2.5
3, Dr. Ted Geller, 03/14/1963, male, 8.0
4, Miss Phoebe Creed, 11/06/1959, female, 5.5
5, Mr. Luke Kenobi, 08/24/1945, male, 2.5
6, Dr. Megan Creed, 03/26/1957, female, 5.5
7, Mr. Ted Rubble, 09/14/1931, male, 3.5
8, Mrs. Monica Balboa, 05/07/1934, female, 1.5
</code></pre>
