Confused yet again: Very Newbie Question
mcl
mcl.office at googlemail.com
Mon Jul 7 08:41:22 EDT 2008
On 7 Jul, 13:09, Jeff <jeffo... at gmail.com> wrote:
> When you call c3.createJoe(c1.fred), you are passing a copy of the
> value stored in c1.fred to your function. Python passes function
> parameters by value. The function will not destructively modify its
> arguments; you must expliticly state your intention to modify an
> object:
>
> class one():
> fred = 'fred'
>
> class three():
> def createJoe(self, myName):
> return "Joe"
>
> def main():
> c1 = one()
> c3 = three()
> c1.fred = c3.createJoe() # Modify c1's attribute, fred, with the
> return value from c3.createJoe
Thank you very much for your helpful replies.
Two questions:
One:
My use of classes is because I want two classes one for global
variables and one for global functions.
A function may set multiple global variable values, so what is the
best way to do this as 'return' only appears to be able to set one
value.
Two:
I am sorry but I do not understand the significance defining a Class
as:
>>> class MyClass(object):
what is object ?
I am using python with Google App Engine, and I only have Alex
Martelli's book up to Python 2.2, if they has any relevance ?
Thanks again for your help. I now understand what my mistakes were and
why I was not getting the results I had expected.
Richard
More information about the Python-list
mailing list