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