[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

>>> 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):
	return anObject
instance = MainClass()

This clearly fails. Suggestions, comments, wit and sarcasm are

Alex Newby 
E-mail: alex at alexnewby.com
Website: http://www.alexnewby.com

More information about the Tutor mailing list