Re: A new to Python question

2005-05-15 Thread Fredrik Lundh
Bernd Nawothnig wrote: You're thinking you're passing the arguments as reference That is the way Fortran handles them: which is one of the things you really love when you link against underdocumented Fortran programs from C. (is that parameter a scalar or an array? crash! oh, an array. how

Re: A new to Python question

2005-05-15 Thread Bengt Richter
On Sun, 15 May 2005 08:00:47 +0200, Fredrik Lundh [EMAIL PROTECTED] wrote: M.E.Farmer wrote: I said exactly what I meant, the parentheses around the values creates a tuple that you have no reference to! repeating it doesn't make you right; no extra tuple is created, and the parens are part of

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
No. You claimed quote This will only create a tuple in memory /quote That is not what I said please do not edit my words and call it a quote! But we just learned that this is not the case. Yes it seems I was proven wrong and have learned much from the discussion ;) That is why I am here to learn

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
Fredrik and Bengt: Thank you for the time. I will study the docs and play with the shell till this is firm. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-15 Thread M.E.Farmer
It looks like the docs could use some examples of the various assignments it refers to. I think something like Bengt posted would be a nice addition if it included assignments with slices and dicts too. Just a thought. M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread Bernd Nawothnig
On 2005-05-14, David wrote: abc(x,y,dotp,sumx,maxv) (x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv) Bernd -- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one. [T. Jefferson] -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread Philippe C. Martin
Hi, You're thinking you're passing the arguments as reference (look at mutable vs non-mutable) Your function returns the values in a tupple (x,y,...); you need to fetch the values from that tupple Regards, Philippe David wrote: Hi I'm trying to teach myself python and so far to good,

Re: A new to Python question

2005-05-14 Thread Bernd Nawothnig
On 2005-05-14, Philippe C. Martin wrote: You're thinking you're passing the arguments as reference That is the way Fortran handles them: [...] Right now I'm taking a simple program I wrote in Fortran Bernd -- Those who desire to give up freedom in order to gain security, will not have,

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
David wrote: Hi I'm trying to teach myself python and so far to good, but I'm having a bit of trouble getting a function to work the way I think it should work. Right now I'm taking a simple program I wrote in Fortran and trying to do it in Python. I got it to work, but now I'm trying to

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
(x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv) This will only create a tuple in memory that has no name to reference it by! How would you access the returned value? If you want a tuple you need to assign all the return vales to a single name. mytup = abc(x,y,dotp,sumx,maxv) M.E.Farmer --

Re: A new to Python question

2005-05-14 Thread Steven Bethard
M.E.Farmer wrote: (x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv) This will only create a tuple in memory that has no name to reference it by! Huh? This binds the names x, y, dotp, sumx and maxv to the values returned by abc: py def abc(*args): ... return args ... py (x,y,dotp,sumx,maxv)

Re: A new to Python question

2005-05-14 Thread David
Thank you very much. Tulpes are really neat now that I've looked at them. So after just fixing it, I changed it up and I would like to show it off now. #! /usr/bin/python #This program takes two vectors and multiplies them #against a 10X10 array. It also then gives the dot product, #sum, and

Re: A new to Python question

2005-05-14 Thread David
Hmm don't know what happened. I guess the formatting got all chewed up. -- http://mail.python.org/mailman/listinfo/python-list

Re: A new to Python question

2005-05-14 Thread Bernd Nawothnig
On 2005-05-14, M.E.Farmer wrote: (x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv) This will only create a tuple in memory that has no name to reference it by! Maybe. But it does not seem to hurt. And I am not sure the tupel _is_ really created in that situation. How would you access the

Re: A new to Python question

2005-05-14 Thread Philippe C. Martin
Yes, I gathered. We all get our habits from somewhere :-) Regards, Philippe Bernd Nawothnig wrote: On 2005-05-14, Philippe C. Martin wrote: You're thinking you're passing the arguments as reference That is the way Fortran handles them: [...] Right now I'm taking a simple program

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
I said exactly what I meant, the parentheses around the values creates a tuple that you have no reference to! It also has a side effect of binding the names inside the tuple to a value and placing them in the local namespace( implicit tuple unpacking ). It might be the same as no parens but it

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
I said exactly what I meant, the parantheses around the values creates a tuple that you have no reference to! It also has a side effect of binding the names inside the tuple to a value and placing them in the local namespace. It might be the same but it isn't very clear. If you want a tuple make

Re: A new to Python question

2005-05-14 Thread Steven Bethard
M.E.Farmer wrote: I said exactly what I meant, the parentheses around the values creates a tuple that you have no reference to! It also has a side effect of binding the names inside the tuple to a value and placing them in the local namespace( implicit tuple unpacking ). It might be the same

Re: A new to Python question

2005-05-14 Thread Steven Bethard
Steven Bethard wrote: I don't know the implementation enough to know whether or not a tuple is actually created when b and c are bound to their values, but I'd be willing to bet that whatever happens to (b, c) is exactly the same as what happens to b, c. Some corroborating evidence: py

Re: A new to Python question

2005-05-14 Thread Bengt Richter
On 14 May 2005 10:44:30 -0700, M.E.Farmer [EMAIL PROTECTED] wrote: [...] Be sure to study up on namespaces, it will ease your Python woes. Namespaces are the most fundamental part of Python that new users don't understand. Namespace mastery will take you far. Just remember there are only two

Re: A new to Python question

2005-05-14 Thread Bengt Richter
On 14 May 2005 13:25:55 -0700, M.E.Farmer [EMAIL PROTECTED] wrote: I said exactly what I meant, the parentheses around the values creates a tuple that you have no reference to! It also has a side effect of I don't understand what you are saying, or meaning ;-) BTW, the function call has nothing

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
It actually is the same, and I don't think implicit or explicit is the difference you should be citing here. Why not it is relevant and true that Python is doing an implicit unpacking of the values in that unnamed tuple. Quoting myself It might be the same as no parens but it isn't very clear. If

Re: A new to Python question

2005-05-14 Thread M.E.Farmer
I explained what i meant in previous post there was nothing more than just a discussion I have no real problem here just more of a sore point in style for me. I feel that parens are quite overloaded and it can be confusing to newbies. But if the parens are just fluff then get rid of them, it is

Re: A new to Python question

2005-05-14 Thread Terry Reedy
M.E.Farmer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] But if the parens are just fluff then get rid of them, it is clearer * at least to me * ;) While I find unnecessary parens on the right of '=' tolerable, I agree as to the style preference. Terry J. Reedy --