[PLUG] Local Python Help?

Quentin Hartman qhartman at gmail.com
Thu Sep 27 22:43:48 UTC 2007


On 9/27/07, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>
>
>    At the top of the importer module I have:
>
> from variablePage import curVar, UoDlow, UoDhigh



This is used to import modules and their assorted classes, not move
instances of those objects (AKA variables and their contents) around.
Remember that python is fully object-oriented, so your "variable" is an
instance of an object of some kind. In order to look at the value of that
object, the object itself needs to be passed to some other object that was
created with your other module.

How I do things like this is that I have a sort of wrapper script that
imports all the modules I need to work with, and then the various objects
that are created for the program are handed around within that wrapper.
Usually, I create  a new instance of the object I want (a page) with the
object that has the data I want as an argument to that object. For a decent
example for how this works in python look at http://www.evolt.org/node/449

It's possible that there are other ways to do this like what you describe,
but I don't know them. I am a low-grade Python programmer on my best days,
so take this with a grain of salt, but it really sounds to me like you are
misunderstanding the idiom that Python uses here.

The Eugene Lug has a python-oriented mailing list. You can sign up for it at
http://www.euglug.org/cgi-bin/mailman/listinfo . It is very low-traffic, but
several good programmers are on it and I have yet to see a question there go
unanswered.

-- 
-Regards-

-Quentin Hartman-



More information about the PLUG mailing list