what do these mean

2012-05-20 Thread e-mail mgbg25171
There's a little forth program written in python here #http://openbookproject.net/py4fun/forth/forth.py I'm struggling to understand what these lines mean. def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()] def rJz (cod,p) : return (p+1,cod[p])[ds.pop()==0] Specifically I'm stuck on what

Re: what do these mean

2012-05-20 Thread Chris Angelico
On Mon, May 21, 2012 at 2:52 AM, e-mail mgbg25171 mgbg25...@blueyonder.co.uk wrote: def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()] def rJz  (cod,p) : return (p+1,cod[p])[ds.pop()==0] Specifically I'm stuck on what (code[p], followed by p+1 does inside the brackets (cod[p],p+1) is a

Re: what do these mean

2012-05-20 Thread Ian Kelly
On Sun, May 20, 2012 at 10:52 AM, e-mail mgbg25171 mgbg25...@blueyonder.co.uk wrote: There's a little forth program written in python here #http://openbookproject.net/py4fun/forth/forth.py I'm struggling to understand what these lines mean. def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()]

Re: what do these mean

2012-05-20 Thread Terry Reedy
On 5/20/2012 1:16 PM, Ian Kelly wrote: On Sun, May 20, 2012 at 10:52 AM, e-mail mgbg25171 mgbg25...@blueyonder.co.uk wrote: There's a little forth program written in python here #http://openbookproject.net/py4fun/forth/forth.py I'm struggling to understand what these lines mean. def rJnz

Re: Function params with **? what do these mean?

2006-03-23 Thread Scott David Daniels
J Rice wrote: I'm sorry for such a basic question, but I haven't been able to phrase a search that gets me an answer and my books are totally silent on this. I have seen a number of python function defs that take parameters of the form (**param1). Looks like a pointer... but my books on

Re: Function params with **? what do these mean?

2006-03-23 Thread Ben Finney
Scott David Daniels [EMAIL PROTECTED] writes: At the risk of being thought of as beating a dead horse, this was a _great_ way to ask this question. [...] So, anyhow, thanks for taking the time to write your question properly. Take that risk, please. There's enough lambasting of (and probably

Function params with **? what do these mean?

2006-03-20 Thread J Rice
I'm sorry for such a basic question, but I haven't been able to phrase a search that gets me an answer and my books are totally silent on this. I have seen a number of python function defs that take parameters of the form (**param1). Looks like a pointer... but my books on python (basic as they

Re: Function params with **? what do these mean?

2006-03-20 Thread Dave Hansen
On 20 Mar 2006 12:46:43 -0800 in comp.lang.python, J Rice [EMAIL PROTECTED] wrote: I'm sorry for such a basic question, but I haven't been able to phrase a search that gets me an answer and my books are totally silent on this. I have seen a number of python function defs that take parameters of

Re: Function params with **? what do these mean?

2006-03-20 Thread Jordan Greenberg
in the parameter list, **param gets a dict of arguments that dont correspond to somthing in the formal parameter list. More examples in the python docs: http://docs.python.org/tut/node6.html#SECTION00672 -- Jordan T. Greenberg --

Re: Function params with **? what do these mean?

2006-03-20 Thread Larry Bates
J Rice wrote: I'm sorry for such a basic question, but I haven't been able to phrase a search that gets me an answer and my books are totally silent on this. I have seen a number of python function defs that take parameters of the form (**param1). Looks like a pointer... but my books on

Re: Function params with **? what do these mean?

2006-03-20 Thread J Rice
Wow, this is incredibly useful! I can understand why an introductory book wouldn't make use of them, but I am really glad to know about them. I can think of a bunch of ways to simply some code I have using this. -- http://mail.python.org/mailman/listinfo/python-list

Re: Function params with **? what do these mean?

2006-03-20 Thread Aahz
In article [EMAIL PROTECTED], Dave Hansen [EMAIL PROTECTED] wrote: On 20 Mar 2006 12:46:43 -0800 in comp.lang.python, J Rice [EMAIL PROTECTED] wrote: I'm sorry for such a basic question, but I haven't been able to phrase a search that gets me an answer and my books are totally silent on this. I

Re: Function params with **? what do these mean?

2006-03-20 Thread Dave Hansen
On 20 Mar 2006 15:45:36 -0800 in comp.lang.python, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Dave Hansen [EMAIL PROTECTED] wrote: [...] It's harder to explain than understand. Try playing with the following function in the python interpreter: def test(a,b='b', *c, **d):

Re: Function params with **? what do these mean?

2006-03-20 Thread Ben Cartwright
Dave Hansen wrote: On 20 Mar 2006 15:45:36 -0800 in comp.lang.python, [EMAIL PROTECTED] (Aahz) wrote: Personally, I think it's a Good Idea to stick with the semi-standard names of *args and **kwargs to make searching easier... Agreed (though kwargs kinda makes my skin crawl).

Re: Function params with **? what do these mean?

2006-03-20 Thread Dave Benjamin
On Mon, 20 Mar 2006, Ben Cartwright wrote: Dave Hansen wrote: On 20 Mar 2006 15:45:36 -0800 in comp.lang.python, [EMAIL PROTECTED] (Aahz) wrote: Personally, I think it's a Good Idea to stick with the semi-standard names of *args and **kwargs to make searching easier... Agreed (though

Re: Function params with **? what do these mean?

2006-03-20 Thread Carl Banks
Aahz wrote: Personally, I think it's a Good Idea to stick with the semi-standard names of *args and **kwargs to make searching easier... I usually do stick to these names (since the I usually only use them when forwarding arguments to another function, where such names are a pretty good