Simple question - stock market simulation

cptn.spoon cptn.spoon at gmail.com
Mon Feb 9 18:10:39 EST 2009


On Feb 9, 6:48 pm, "Hendrik van Rooyen" <m... at microcorp.co.za> wrote:
> "cptn.spoon" <cp...... at gmail.com> wrote:
>
> On Feb 9, 3:58 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
>
> >Thanks Paul! I thought this might be the case. So how would I get the
> >StockMarket class instance to contain many Stock class instances and
> >then be able to iterate through them? I'm guessing the basic structure
> >would be as follows...but I think I'm wrong:
>
> >class StockMarket:
> >  pass
>
> No.
> At this level, just use a list of instances of your Stock class.
>
> - Hendrik

How do I get a list of instances of a particular class? Is there a way
to do this dynamically?

Also, what would be the way of dynamically creating an instance of a
class based on user input (ie a user wants to create a new instance of
the Stock class via shell input)?

I'm not sure if I have the wrong mindset here.

Thanks for any help
~Phil



More information about the Python-list mailing list