Re: Beginning Question about Python functions, parameters...

2009-11-25 Thread Lie Ryan
astral orange wrote: As for the "class Name():" example above? Even though I haven't seen exactly what purpose 'self' serves In many other programming language, self (or this, or Me) refers the the current class instance. In some languages, you can refer to an instance attribute without an e

Re: Beginning Question about Python functions, parameters...

2009-11-25 Thread Bruno Desthuilliers
astral orange a écrit : On Nov 23, 10:37 pm, r wrote: (snip) This is a horrible example to show noobs. I think the OP could better understand this as a class EVEN though the OP may or may not know what a class *is* yet. class Name(): def __init__(self, first, middle, last):

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread r
On Nov 24, 9:45 am, astral orange <457r0...@gmail.com> wrote: > > As for the "class Name():" example above? Even though I haven't seen > exactly what purpose 'self' serves > yet I can follow and understand what is going on very easily, that > helps out tremendously. > Very clearly written...Thank y

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: remember exactly what was stored. Maybe a typo. That's a bug in the store() function # as posted def store(data, full_name): names = full_name.split() if len(names) == 2: names.insert(1, '') labels = 'first', 'middle', 'last' for label,

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread astral orange
On Nov 23, 10:37 pm, r wrote: > On Nov 23, 11:19 am, astral orange <457r0...@gmail.com> wrote: > > > > > Hi, I am trying to teach myself Python and have a good book to help me > > but I am stuck on something and I would like for someone to explain > > the following piece of code for me and what it

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread Peter Otten
Terry Reedy wrote: > astral orange wrote: > >> As far as the program. I did add print statements such as print >> (MyNames) and got back: >> >> {'middle': {}, 'last': {'Smith': ['John Larry Smith']}, 'first': {}} > > Hmmm, as I understood the code, either that should be ... 'last': {} ... > bef

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread r
On Nov 23, 11:19 am, astral orange <457r0...@gmail.com> wrote: > Hi, I am trying to teach myself Python and have a good book to help me > but I am stuck on something and I would like for someone to explain > the following piece of code for me and what it's actually doing. > Certain parts are very c

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Terry Reedy
astral orange wrote: As far as the program. I did add print statements such as print (MyNames) and got back: {'middle': {}, 'last': {'Smith': ['John Larry Smith']}, 'first': {}} Hmmm, as I understood the code, either that should be ... 'last': {} ... before the first store(), as you seem to b

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread astral orange
On Nov 23, 4:35 pm, Terry Reedy wrote: > astral orange wrote: > > Yes, lines 104-111 is really where my problem lies in understanding > > what is going on here. > > I am beginner so this stuff seems a little unwieldy at the moment. :) > > I *did* invest $40 > > Water under the bridge. Focus on the

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Terry Reedy
astral orange wrote: Yes, lines 104-111 is really where my problem lies in understanding what is going on here. I am beginner so this stuff seems a little unwieldy at the moment. :) I *did* invest $40 Water under the bridge. Focus on the future... into this book so it' what I have to work wi

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 11:14 AM, astral orange <457r0...@gmail.com> wrote: > But back to the example, on line 104 I see there's a call to the > lookup function, passing 3 > parameters ('data', which I think is a nested dictionary, label > (first, middle, last) and name). > > But I am getting lo

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 10:26 AM, j wrote: > What I am not totally sure about is when the store function callsthe > lookup function and does "return data[label].get(name)", that line > "trips" me up somethen the lookup function returns that back to > the store function, assigns the data to th

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread astral orange
On Nov 23, 1:17 pm, "Diez B. Roggisch" wrote: > astral orange wrote: > > Hi, I am trying to teach myself Python and have a good book to help me > > but I am stuck on something and I would like for someone to explain > > the following piece of code for me and what it's actually doing. > > Certain p

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread MRAB
j wrote: On Nov 23, 12:37 pm, Neo wrote: astral orange schrieb: Hi, I am trying to teach myself Python and have a good book to help me but I am stuck on something and I would like for someone to explain the following piece of code for me and what it's actually doing. Certain parts are very

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread david wright
- Original Message From: j To: python-list@python.org Sent: Mon, November 23, 2009 10:26:42 AM Subject: Re: Beginning Question about Python functions, parameters... On Nov 23, 12:37 pm, Neo wrote: > astral orange schrieb: > > > > > Hi, I am trying to teach myself

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread j
On Nov 23, 12:37 pm, Neo wrote: > astral orange schrieb: > > > > > Hi, I am trying to teach myself Python and have a good book to help me > > but I am stuck on something and I would like for someone to explain > > the following piece of code for me and what it's actually doing. > > Certain parts a

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Diez B. Roggisch
astral orange wrote: > Hi, I am trying to teach myself Python and have a good book to help me > but I am stuck on something and I would like for someone to explain > the following piece of code for me and what it's actually doing. > Certain parts are very clear but once it enters the "def store(da

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Neo
astral orange schrieb: > Hi, I am trying to teach myself Python and have a good book to help me > but I am stuck on something and I would like for someone to explain > the following piece of code for me and what it's actually doing. > Certain parts are very clear but once it enters the "def store(d

Beginning Question about Python functions, parameters...

2009-11-23 Thread astral orange
Hi, I am trying to teach myself Python and have a good book to help me but I am stuck on something and I would like for someone to explain the following piece of code for me and what it's actually doing. Certain parts are very clear but once it enters the "def store(data, full_name): " function