is it ok to not define class defaults?
<p>sparing the details of context and why i care...</p>

<p>is it okay to do this:</p>

<pre><code>class IsThisOk(object):
    def __init__( self, **kwargs ):
        for k in kwargs:
            setattr( self, k, kwargs[k] )
obj = IsThisOk( apples=2 , oranges=2 )
</code></pre>

<p>because I've always approached it as:</p>

<pre><code>class OptionB(object):
    apples = None
    oranges = None
    """class defaults"""
    def __init__( self, **kwargs ):
        for k in kwargs:
            setattr(self,k,kwargs[k])
b = OptionB( apples=2 , oranges=2 )
</code></pre>

<p>=====</p>

<p>edit :</p>

<p>i originally had this in the above , which is something I shouldn't have...</p>

<pre><code>class OptionA(object):
    """set self.k but with class defaults"""
    apples = None
    oranges = None
    def __init__( self, **kwargs ):
        for k in kwargs:
            self.k = kwargs[k]
a = OptionA( apples=2 , oranges=2 )
</code></pre>

<p>This all came from me trying to optimize some code. </p>

<p>i also noted that::</p>

<pre><code>    for k in kwargs:
        setattr( self, k, kwargs[k] )
</code></pre>

<p>is a bit faster than</p>

<pre><code>    for k,v in kwargs.iteritems():
        setattr( self, k, v )
</code></pre>
