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
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
[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
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):
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
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
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
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
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?
>
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
10 matches
Mail list logo