Re: There's GOT to be a better way!

2005-04-09 Thread Earl Eiland
On Thu, 2005-03-03 at 16:43, Steve Holden wrote: > Earl Eiland wrote: > On Thu, 2005-03-03 at 15:11, Steve Holden wrote: > > Earl Eiland wrote: > > I'm writing my first program where I call custom modules. The 'global' > command doesn't seem to apply, so how do I change a variable internally > i

Re: There's GOT to be a better way!

2005-03-04 Thread [EMAIL PROTECTED]
Good call. I was just trying to be generic in my quickly put-together example. It's been a while since I've used Python so these things I easily forget :) 'object' here would be more aptly named 'MyObject'. -- http://mail.python.org/mailman/listinfo/python-list

Re: There's GOT to be a better way!

2005-03-03 Thread Kent Johnson
[EMAIL PROTECTED] wrote: This would be a good case to use OO design, imo. The following works fine. Simply instantiate the object, call the method, and you can access (and manipulate) the "module's" variable to your heart's content. module.py class object: Ouch. Use a different name than

Re: There's GOT to be a better way!

2005-03-03 Thread [EMAIL PROTECTED]
This would be a good case to use OO design, imo. The following works fine. Simply instantiate the object, call the method, and you can access (and manipulate) the "module's" variable to your heart's content. module.py class object: def __init__(self):

Re: There's GOT to be a better way!

2005-03-03 Thread Earl Eiland
On Thu, 2005-03-03 at 16:46, Steven Bethard wrote: > Earl Eiland wrote: > > module.py > > def A(): > > test = 1 > > for x in range(10): B() > > > > def B(): > > test = test + 1 > > > > > > main.py > > import module > > module.A() > > > > T

Re: There's GOT to be a better way!

2005-03-03 Thread Earl Eiland
On Thu, 2005-03-03 at 16:43, Steve Holden wrote: > Earl Eiland wrote: > > On Thu, 2005-03-03 at 15:11, Steve Holden wrote: > > > >>Earl Eiland wrote: > >> > >>>I'm writing my first program where I call custom modules. The 'global' > >>>command doesn't seem to apply, so how do I change a variable

Re: There's GOT to be a better way!

2005-03-03 Thread Steven Bethard
Earl Eiland wrote: module.py def A(): test = 1 for x in range(10): B() def B(): test = test + 1 main.py import module module.A() This will fail, unless test is passed and returned. (Sorry if this sent twice. I

Re: There's GOT to be a better way!

2005-03-03 Thread Steve Holden
Earl Eiland wrote: On Thu, 2005-03-03 at 15:11, Steve Holden wrote: Earl Eiland wrote: I'm writing my first program where I call custom modules. The 'global' command doesn't seem to apply, so how do I change a variable internally in a module without passing it down n layers, and then back out agai

Re: There's GOT to be a better way!

2005-03-03 Thread Earl Eiland
On Thu, 2005-03-03 at 15:11, Steve Holden wrote: > Earl Eiland wrote: > > I'm writing my first program where I call custom modules. The 'global' > > command doesn't seem to apply, so how do I change a variable internally > > in a module without passing it down n layers, and then back out again? >

Re: There's GOT to be a better way!

2005-03-03 Thread Steve Holden
Earl Eiland wrote: I'm writing my first program where I call custom modules. The 'global' command doesn't seem to apply, so how do I change a variable internally in a module without passing it down n layers, and then back out again? You are correct in assuming that global isn't what you want - it