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
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):
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
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,
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
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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
Boris Ozegovic a écrit :
> Bruno Desthuilliers wrote:
>
>
>>Why don't you just read the source code ? Django is free software, you
>>know !-)
>
> Yes, I know. :)
>
>>What about something like:
>
>
>>def filter(self, **kw):
>> for argname, value in kw.items():
>> fieldname, op = arg
Paul Rubin wrote:
> Since split is applied to argname, it retrieves 'question' and 'startswith'.
Exactly. :) And, 'questions' and 'startswith' are two string, and not
references at Poll.question, or more precisely, instanceOfPoll.question.
I suppose this is what I was looking for:
__getattri
Boris Ozegovic <[EMAIL PROTECTED]> writes:
> > def filter(self, **kw):
> >for argname, value in kw.items():
> > fieldname, op = argname.split('__', 1)
>
> Yes, this is what confused me in the first place: how to separate
> arguments. If you call split, and split returns list of String, t
Bruno Desthuilliers wrote:
> Why don't you just read the source code ? Django is free software, you
> know !-)
Yes, I know. :)
> What about something like:
> def filter(self, **kw):
>for argname, value in kw.items():
> fieldname, op = argname.split('__', 1)
Yes, this is what conf
Boris Ozegovic <[EMAIL PROTECTED]> writes:
> >>> Poll.objects.filter(question__startswith='What')
>
> This 'question__startswith' is the problem. What is the common idiom for
> this type od arguments, so I can Google it?
You can refer to function args in Python by name, e.g. define a function
>>> Poll.objects.filter(question__startswith='What')
That is an example of a keyword argument. You can read about it in the
Python Tutorial:
http://docs.python.org/tut/node6.html#SECTION00672
-Matt
--
http://mail.python.org/mailman/listinfo/python-list
Boris Ozegovic a écrit :
> Hi, I'am still learning Python and while reading Django tutorial couldn't
> understand this part:
>
> class Poll(models.Model):
> question = models.CharField(maxlength=200)
> pub_date = models.DateTimeField('date published')
>
>
> # Django provides a rich d
Hi, I'am still learning Python and while reading Django tutorial couldn't
understand this part:
class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
# Django provides a rich database lookup API that's entirely driv
27 matches
Mail list logo