passing object between classes
Duncan Booth
duncan.booth at invalid.invalid
Mon Sep 21 07:44:45 EDT 2009
daved170 <daved170 at gmail.com> wrote:
> Hi everybody,
> I built my owen log obj as a class.
> I'm passing it to another object (actually to a thread).
> When I run my app it raise error at the line when I'm using that log
> obj. is there any problem with the concept of passing object as I do
> it?
> How can I do that?
>
> class A:
> def foo1:
> myLog = cLog()
> myYhread = cThread(myLog)
> myThread.start()
>
> class cThread:
> def __init__(self,in_myLog):
> sel.LogObj = in_myLog
>
> def run():
> sel.LogObj.writeLine("HI")
>
> thanks
> Dave
>
Please always post real code and state the exact error you get. That will
maximise the chance that you get a useful answer.
The code you posted will fail for numerous reasons and I can't guess
whether you have a problem with indentation, a problem because you
misspelled 'self' as 'sel', or because you missed out the 'self' parameter
altogether on a method, or perhaps your LogObj simply doesn't have a
writeLine method.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list