Class or Dictionary?

Martin De Kauwe mdekauwe at gmail.com
Mon Feb 14 11:11:35 CET 2011


On Feb 14, 8:57 pm, Martin De Kauwe <mdeka... at gmail.com> wrote:
> On Feb 14, 8:51 pm, Dave Angel <da... at ieee.org> wrote:
>
>
>
>
>
> > On 01/-10/-28163 02:59 PM, Martin De Kauwe wrote:
>
> > > <snip>
>
> > > from other_model import OtherSubModel
> > > class Model:
>
> > >      def __init__(self):
>
> > >          # included other external modules (i.e. in other files)
> > >          om =therSubModel()
>
> > >      def run(self):
> > >          # call other submodel and pass params
> > >          om.run(params)
>
> > What's om supposed to be?  You define a local variable in one method,
> > and try to use it in a different one ????
>
> > Perhaps you meant  self.om =
>
> >  > class OtherSubModel:
> >  >     def __init__(self):
> >  >         #some stuff
> >  >
> >  >     def run(params):
>
> > You're missing a self here in the formal parameter list.
>
> > DaveA
>
> I was trying to write a smaller version of broadly what I think i am
> doing, perhaps I am not implementing it correctly. I have one model
> which I have coded as a class, there were a few parts which could be
> used separately (sub-models). So I decided to make them separate
> classes in separate files which I *thought* I could just join up into
> one package at run time. This way I could also use these modules
> separately.
>
> So in the dummy example
>
> the other file is imported
>
> from other_model import OtherSubModel
>
> amd om = OtherSubModel was me making an instance of it? And then when
> I called the *run* part of this sub-model I was passing it the
> parameter file. I am sensing I have this wrong?

oh and yes i did mean self.om.run(params), sorry!



More information about the Python-list mailing list