Standard behaviour of a getSomething method

Lee Harr missive at frontiernet.net
Wed Jul 23 17:13:48 EDT 2003


In article <mailman.1058966922.4133.python-list at python.org>, Batista, Facundo:
> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
> 

> When I want to know about a attribute (e.g.: myAttrib) of an object, I
> should use the specific method (e.g.: getMyAttrib).
> 
> Considering that this attribute is always another object (everything is =
> an
> object in Python), what should getMyAttrib do?
> 
> 	1) Return the object
> 	2) Return a copy of the object
> 

I do not think there is a definite rule regarding this. However,
whichever one it does, you should probably document it  :o)



> How do I return a copy of the object?
> 

You can use the copy module to create either a shallow or deep copy.






More information about the Python-list mailing list