Re: class instance scope

2006-07-24 Thread Jeethu Rao
You could possibly make the log class a singleton or a borg. Jeethu Rao Ritesh Raj Sarraf wrote: >>> log = foo.log(x, y, z) >>> >>> > > Resulting line is: > log = foo.log(x, y, z) > global log > > Making the instance "log" global makes it accessible to all the > functions. > > Now I have o

Re: class instance scope

2006-07-24 Thread Ritesh Raj Sarraf
> > log = foo.log(x, y, z) > > Resulting line is: log = foo.log(x, y, z) global log Making the instance "log" global makes it accessible to all the functions. Now I have only one question, Is this a correct way to do it ? Or are there better way ? Ritesh -- http://mail.python.org/mailman/list

Re: class instance scope

2006-07-24 Thread Ritesh Raj Sarraf
Steve Holden wrote: > Ritesh Raj Sarraf wrote: > > But when I call the same method from some functions which are in > > bar.py, it fails giving me the following error: > > > > NameError: global name 'log' is not defined > > > Well, that's preumbaly because your > >log = foo.log(x, y, z) > > st

Re: class instance scope

2006-07-24 Thread Steve Holden
Ritesh Raj Sarraf wrote: > Hi, > > I have a class defined in a file called foo.py > > In bar.py I've imported foo.py > In bar.py's main function, I instantiate the class as follows: > > log = foo.log(x, y, z) > > Now in main I'm able to use log.view(), log.error() et cetera. > Correct. Because

class instance scope

2006-07-24 Thread Ritesh Raj Sarraf
Hi, I have a class defined in a file called foo.py In bar.py I've imported foo.py In bar.py's main function, I instantiate the class as follows: log = foo.log(x, y, z) Now in main I'm able to use log.view(), log.error() et cetera. But when I call the same method from some functions which are i