Python values with units
<p>I need to keep track of units on float and int values in Python, but I don't want to use an external package like magnitude or others, because I don't need to perform operations on the values. Instead, all I want is to be able to define floats and ints that have a unit attribute (and I don't want to add a new dependency for something this simple). I tried doing:</p>

<pre><code>class floatwithunit(float):

    __oldinit__ = float.__init__

    def __init__(self, *args, **kwargs):
        if 'unit' in kwargs:
            self.unit = kwargs.pop('unit')
        self.__oldinit__(*args, **kwargs)
</code></pre>

<p>But this doesn't work at all:</p>

<pre><code>In [37]: a = floatwithunit(1.,unit=1.)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/tom/&lt;ipython console&gt; in &lt;module&gt;()

TypeError: float() takes at most 1 argument (2 given)

Any suggestions?
</code></pre>
