[Tutor] Accessing class instances
Karl Pflästerer
sigurd at 12move.de
Wed Mar 17 11:09:23 EST 2004
On 17 Mar 2004, Steve George <- stevege at i-way.net.uk wrote:
> I'm having a bit of a problem understanding how to use modules and
> class instances.
To be able to help you it helps a lot if you write a small example where
your problems can be seen.
> The basic idea in my program is to have a number of classes as follows:
> MainProgram()
> "" Does all my start-up stuff and controls it """
> Options()
> """ parses options and stores them as attributes"""
> DataLoader()
> """ Loads a data file and allows operations on it """
I'm not sure if it's a good idea to have her three sparate classes. But
before we know what each class does it's hard to tell.
> I put MainProgram() and Options() classes into one single text file
> and my DataLoader() class into another.
> When I instantiate my DataLoader object I want it to look at the
> instance of my Options() class and pull some information from it. At
> the moment I get:
> in get_price
> print Opts.line_size
> NameError: global name 'Opts' is not defined
> I think I have two problems going on:
In which file is that code? How did you import the other file? (with
example code it would be clear).
Karl
--
Please do *not* send copies of replies to me.
I read the list
More information about the Tutor
mailing list