Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Terry Reedy
"Gregory Piñero" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > how references work in Python 'references' are an implementation detail and a metaconcept used to talk about Python but are not part of the language spec itself. > when passing arguments into functions? Python does

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Christopher Subich
Gregory Piñero wrote: > So what if I do want to share a boolean variable like so: Well, the easiest way is to wrap it in a list: mybool = [True] mybool[0] = False mybool[0] = True and so on. Alternately, what is this boolean attached to that's so significant? Sharing an arbitrary boolean, with

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Gregory Piñero
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: sharedbool=True class cls1:pass cl=cls1() cl.sharedbool1=shared

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Rocco Moretti
Christopher Subich wrote: > Rocco Moretti wrote: > >> 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. > > > +1 MOTW (Metaphor of the Week) Thanks, but please note it's not really mine - I've seen it s

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Rocco Moretti
Dennis Lee Bieber wrote: > On Tue, 09 Aug 2005 10:39:29 -0500, Rocco Moretti > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >>Change it to "the object referenced by y is assigned to the name of x", >>and you're closer to the truth. > > In a more simplistic view, I'

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Christopher Subich
Rocco Moretti wrote: > 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. +1 MOTW (Metaphor of the Week) -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Christopher Subich
infidel wrote: >>in Python equality rebinds the name > > > Assignment (=) rebinds the name. Equality (==) is something else > entirely. Good catch. I was thinking of it as the "equals" operator. -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Christopher Subich
Dennis Lee Bieber wrote: > In a more simplistic view, I'd reverse the phrasing... The name > "x" is assigned to the object "y" (implying it is no longer attached to > whatever used to have the name) No, because that'd imply that the object 'y' somehow keeps track of the names assigned to it

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Rocco Moretti
Gregory Piñero wrote: > Ahh, so it's a mutable thing. That makes sense that I can't change a > mutable object and thus can't affect it outside of the function. If you meant "immutable" for the second mutable, you're right. > Does > that mean Python functions aren't always byref, but are someti

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Dan
> Does that mean Python functions aren't always byref, > but are sometimes byval for nonmutables? Don't think of it as byref or byval (as they are used in Visual Basic). All parameters are passed the same way: by reference instead of by copy. It's a little difficult to get your head around, but

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Gregory Piñero
Ahh, so it's a mutable thing. That makes sense that I can't change a mutable object and thus can't affect it outside of the function. Does that mean Python functions aren't always byref, but are sometimes byval for nonmutables? -Greg On 8/9/05, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread infidel
> in Python equality rebinds the name Assignment (=) rebinds the name. Equality (==) is something else entirely. -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Rocco Moretti
Christopher Subich wrote: > Gregory Piñero wrote: > >> Hey guys, would someone mind giving me a quick rundown of how >> references work in Python when passing arguments into functions? The >> code below should highlight my specific confusion: This URL is always tossed out: http://starship.pytho

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Christopher Subich
Gregory Piñero wrote: > Hey guys, would someone mind giving me a quick rundown of how > references work in Python when passing arguments into functions? The > code below should highlight my specific confusion: All arguments are passed by reference, but in Python equality rebinds the name. > >

Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread Gregory Piñero
Hey guys, would someone mind giving me a quick rundown of how references work in Python when passing arguments into functions? The code below should highlight my specific confusion: bool1=True lst1=[1,2,3] def func1(arg1): arg1.append(4) def func2(arg1): arg1=False >>func1(lst1) >>lst1 [1,2,