Re: [Tutor] Accessing variables from other modules

2018-09-05 Thread Chip Wachob
Alan, Thanks for your comments. I just forwarded a copy of a message to the list that I inadvertently sent as a reply only. So in that message there's information about the code. Thank you for confirming that once the interpreter is finished running my script that all the data is gone. The boa

Re: [Tutor] Accessing variables from other modules

2018-09-04 Thread Alan Gauld via Tutor
On 04/09/18 16:10, Chip Wachob wrote: > (like I would do in C). I then used the import statement to 'include' > them into the main.py file. OK a basically good idea but how did you use the import statement? There are many forms: import foo from foo import name1, name2,... from foo import * impo

Re: [Tutor] Accessing variables from other modules

2018-09-04 Thread Steven D'Aprano
Hi Chip, and welcome! On Tue, Sep 04, 2018 at 11:10:36AM -0400, Chip Wachob wrote: > I'll refrain from posting a bunch of code, but here is the 5000 foot view: Not posting a mountain of code is a great idea, but from 5000 ft away we can't see what is going on. Try posting *a little bit of code

[Tutor] Accessing variables from other modules

2018-09-04 Thread Chip Wachob
Hello, Hoping that this comes through as text only. Not sure how to force that with Gmail. Very new to Python and trying to follow the instructions I've read on the tutorial and other places. But, I'm not meeting with any success. I have a feeling this is something simple but a search of the ar

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-31 Thread Robert Lummis
These replies are great! Thanks to everyone who took the trouble to respond and explain. I'll need some time to digest what you say and put it to use but I'm sure your suggestions will be a huge help. On Fri, Oct 30, 2009 at 7:55 PM, Alan Gauld wrote: > "Robert Lummis" wrote > >> I want to move

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread spir
Le Fri, 30 Oct 2009 18:39:42 -0400, Robert Lummis s'exprima ainsi: > I want to move some functions from my "main" program file to a module > file because the main file is getting too big for convenience. The > functions access arrays (lists of lists) that are defined and > initialised in the main

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread Dave Angel
Kent Johnson wrote: On Fri, Oct 30, 2009 at 6:39 PM, Robert Lummis wrote: I want to move some functions from my "main" program file to a module file because the main file is getting too big for convenience. The functions access arrays (lists of lists) that are defined and initialised in the

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread Kent Johnson
On Fri, Oct 30, 2009 at 6:39 PM, Robert Lummis wrote: > I want to move some functions from my "main" program file to a module > file because the main file is getting too big for convenience. The > functions access arrays (lists of lists) that are defined and > initialised in the main file. How do

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread Alan Gauld
"Robert Lummis" wrote I want to move some functions from my "main" program file to a module file because the main file is getting too big for convenience. Good idea! functions access arrays (lists of lists) that are defined and initialised in the main file. How do I reference the main file

[Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread Robert Lummis
I want to move some functions from my "main" program file to a module file because the main file is getting too big for convenience. The functions access arrays (lists of lists) that are defined and initialised in the main file. How do I reference the main file arrays from statements within the mod

Re: [Tutor] Accessing Variables

2005-10-05 Thread Alan Gauld
> If I have ONE.py file with some variable a, and ONE imports TWO, which > has a variable b, can TWO access variable a (I don't think so, but I > just thought I'd check). Correct you can't do it. And quite rightly so because trying to do so would indicate a faulty design! When we import a module i

Re: [Tutor] Accessing Variables

2005-10-05 Thread Kent Johnson
Matt Williams wrote: > Dear List, > > I'm trying to clarify something about accessing variables. > > If I have ONE.py file with some variable a, and ONE imports TWO, which > has a variable b, can TWO access variable a (I don't think so, but I > just thought I'd check). You are right. TWO can imp

Re: [Tutor] Accessing Variables

2005-10-05 Thread paul brian
Sort ofnot really When a module is imported the following things happen import ONE a module object (dict essentially) named ONE is created. This is the module ONE.py's namespace. The module object is added to sys.modules the code in the object is executed inside the ONE dict (namespace) now

Re: [Tutor] Accessing Variables

2005-10-05 Thread Adam
What you can do is if ONE.py has a class with the variable a, in it, you can pass the class instance (ie. self) and then you can call any function or get any global class variable. eg def foo(parent):     print parent.aOn 05/10/05, Matt Williams <[EMAIL PROTECTED]> wrote: Dear List,I'm trying to cl

[Tutor] Accessing Variables

2005-10-05 Thread Matt Williams
Dear List, I'm trying to clarify something about accessing variables. If I have ONE.py file with some variable a, and ONE imports TWO, which has a variable b, can TWO access variable a (I don't think so, but I just thought I'd check). I guess the way round this is just to make some classes & obj