Re: Functions, parameters

2007-02-08 Thread Bruno Desthuilliers
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

Re: Functions, parameters

2007-02-08 Thread Boris Ozegovic
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

Re: Functions, parameters

2007-02-08 Thread Paul Rubin
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

Re: Functions, parameters

2007-02-08 Thread Boris Ozegovic
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

Re: Functions, parameters

2007-02-08 Thread Paul Rubin
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

Re: Functions, parameters

2007-02-08 Thread Matimus
>>> 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

Re: Functions, parameters

2007-02-08 Thread Bruno Desthuilliers
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