<div>I've now written my first set of Classes to do some fairly specific processing for work I do. I have a few questions.</div>
<div> </div>
<div>First, in looking through what I've done, I basically just incorporated all my previous scripts into classes... they are still highly specific to my application, though I did try to make them somewhat 'reusable' or general. It is difficult though, as portions required hardcoding. For that I used the __init__ method to define a bunch of 'hardcoded' variables, that could then be set if they were passed on initiation.
</div>
<div> </div>
<div>I guess, I'm writing because I'm wondering now what people think about writing classes versus just using scripts for things that are so specific. It's hard for me to give an example, or show what I'm doing, but I would appreciate thoughts on that matter.
</div>
<div> </div>
<div>One thing I am struggling with is how to assign *args and **kwargs if they are passed, and how to ignore them if they are not... right now I do this:</div>
<div> </div>
<div>def myfunc(self, *args,**kwargs):</div>
<div> a=self.a</div>
<div> b=self.b</div>
<div> kwa=self.kwa</div>
<div> kwb=self.kwb</div>
<div> try: </div>
<div> a=args[0]; b=args[1]</div>
<div> kwa=kwargs['a']</div>
<div>
<div> kwb=kwargs['b']</div></div>
<div> except: pass</div>
<div> </div>
<div> </div>
<div>Where self.X is defined in the __init__ of the class. Is that correct?</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>