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
> > 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
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
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
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