[Tutor] Passing objects
Alex Newby
alex at alexnewby.com
Thu Jul 8 04:49:39 CEST 2004
Continuing on my quest to understand how to pass around objects with
ming(anything?)...
>>> def foo(shape):
shape = SWFShape()
return shape
>>> r = ""
>>> foo(r)
<ming.SWFShape instance at 0x00B9CB20>
>>> r
''
>>>
I am somewhat mystified by the above behaviour. A class instance is
instantiated, but r remains a string. How can I pass an instance of an
object to a function, that will permit the objects methods applied in
the function?
I was exploring the utility of the following.
def bar(Object):
Object.MainClassFunction(args)
return anObject
instance = MainClass()
bar(instance)
This clearly fails. Suggestions, comments, wit and sarcasm are
appreciated...
---------------------------------
Sincerely,
Alex Newby
E-mail: alex at alexnewby.com
Website: http://www.alexnewby.com
More information about the Tutor
mailing list