Re: Passing arguments to function - (The fundamentals are confusingme)
Thanks everyone. I understand now. Everything is a reference, all
that matters is whether I can go inside the "cubbyhole" and change
something. Immutables don't allow this.
So what if I do want to share a boolean variable like so:
<code>
sharedbool=True
class cls1:pass
cl=cls1()
cl.sharedbool1= sharedbool
sharedbool=Fals e
[color=blue][color=green]
>>cl.sharedbool 1[/color][/color]
True #but I wanted false!
</code>
My guess having read this threat would be to make a simple wrapper
class for a boolean so I'm changing something inside the object
instead of reassigning it?
<code>
class bigbool:
/t def __init__(self,t f):
/t/t self.val=tf
/t def setval(self,tf) :
/t/t self.val=tf
</code>
Is there an easier way?
-Greg
On 8/9/05, Rocco Moretti <roccomoretti@h otpop.com> wrote:[color=blue]
> Christopher Subich wrote:[color=green]
> > Rocco Moretti wrote:
> >[color=darkred]
> >> Variables in Python are names. They aren't the cubbyholes into which
> >> you put values, they are sticky notes on the front of the cubby hole.[/color]
> >
> >
> > +1 MOTW (Metaphor of the Week)[/color]
>
> Thanks, but please note it's not really mine - I've seen it somewhere
> else before. I thought it was from the website I linked earlier[1], but
> now I'm a little embarrased to find out that isn't, and I have no clue
> where it's from.
>
> [1] http://starship.python.net/crew/mwh/...jectthink.html
> --
> http://mail.python.org/mailman/listinfo/python-list
> [/color]
--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)
Thanks everyone. I understand now. Everything is a reference, all
that matters is whether I can go inside the "cubbyhole" and change
something. Immutables don't allow this.
So what if I do want to share a boolean variable like so:
<code>
sharedbool=True
class cls1:pass
cl=cls1()
cl.sharedbool1= sharedbool
sharedbool=Fals e
[color=blue][color=green]
>>cl.sharedbool 1[/color][/color]
True #but I wanted false!
</code>
My guess having read this threat would be to make a simple wrapper
class for a boolean so I'm changing something inside the object
instead of reassigning it?
<code>
class bigbool:
/t def __init__(self,t f):
/t/t self.val=tf
/t def setval(self,tf) :
/t/t self.val=tf
</code>
Is there an easier way?
-Greg
On 8/9/05, Rocco Moretti <roccomoretti@h otpop.com> wrote:[color=blue]
> Christopher Subich wrote:[color=green]
> > Rocco Moretti wrote:
> >[color=darkred]
> >> Variables in Python are names. They aren't the cubbyholes into which
> >> you put values, they are sticky notes on the front of the cubby hole.[/color]
> >
> >
> > +1 MOTW (Metaphor of the Week)[/color]
>
> Thanks, but please note it's not really mine - I've seen it somewhere
> else before. I thought it was from the website I linked earlier[1], but
> now I'm a little embarrased to find out that isn't, and I have no clue
> where it's from.
>
> [1] http://starship.python.net/crew/mwh/...jectthink.html
> --
> http://mail.python.org/mailman/listinfo/python-list
> [/color]
--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)
Comment