Re: Possible Basic kwargs question.

2013-04-17 Thread Rainy
When the definition is method(self, **kwargs), you ARE asking variable named kwargs. If you want to accept one dict object, it should be: method(self, mydict). If you want to accept variable list of args, it should be method(self, *mylist) -ak On Wednesday, April 17, 2013 12:59:21 AM UTC-4, jayh

Re: Possible Basic kwargs question.

2013-04-16 Thread Mario Gudelj
I think this might be a useful article for you http://agiliq.com/blog/2012/06/understanding-args-and-kwargs/ On 17 April 2013 15:45, Brad Pitcher wrote: > I see what you're saying. Maybe you're looking for something more like > this? > > def method1(self, param1=sensible_default, param2=sensibl

Re: Possible Basic kwargs question.

2013-04-16 Thread Brad Pitcher
I see what you're saying. Maybe you're looking for something more like this? def method1(self, param1=sensible_default, param2=sensible_default, param3=sensible_default): print param1, param2, param3 The variable names must be specified in the method arguments like above if you wish to refere

Re: Possible Basic kwargs question.

2013-04-16 Thread jayhalleaux
but if I did that then i would have a variable named kwargs. and it would be print kwargs['param1'], etc Why even unpack the dictionary? I could just pass the dictionary instead. On Tuesday, April 16, 2013 11:08:42 PM UTC-4, Brad Pitcher wrote: > > It should be: > model.method1(**params) > On

Re: Possible Basic kwargs question.

2013-04-16 Thread Brad Pitcher
It should be: model.method1(**params) On Apr 16, 2013 7:49 PM, "jayhalleaux" wrote: > Not really a Django question but I'm trying to create a model method that > does not have a fixed set of parameters. > > models.py > Class Model_A(model.Model): > ... > > def method1(self, **kwargs): > > print p

Possible Basic kwargs question.

2013-04-16 Thread jayhalleaux
Not really a Django question but I'm trying to create a model method that does not have a fixed set of parameters. models.py Class Model_A(model.Model): ... def method1(self, **kwargs): print param1, param2, param3 views.py params = dict( param1=something1, param2=something2, param3=somethi