how to call a function in python with different number of attributes and with another logic?
<p>I have a function in python that has 2 arguments: for example </p>

<pre><code> def get_shiff(instance):
     total=0
     if instance.x:
         total+=instance.x/2
     elif instance.y:
         total.+=instance.y*40
     return total
</code></pre>

<p>Can I call this function in python in another file as this:</p>

<pre><code>  def get_shiff(instance,type)
    # the same thing for total but add this logic
       if type=="standard" :
         total+=instance.z*100
         return total
</code></pre>

<p>Short answer Yes, but maybe not as you expect. Have a look at the folowing:</p>

<pre><code>def fn(a, b, c= None):
    if c is not None:
        return a+b+c
    else:
        return a+b

print fn(1,2,3)
&gt;&gt; 6
print fn(1,2)
&gt;&gt; 3
</code></pre>

<p>Applying this to your example:</p>

<pre><code>def get_shiff(instance, shift=None):
     total=0
     if shift is None:
         if instance.x:
             total+=instance.x/2
         elif instance.y:
             total.+=instance.y*40
         return total
     elif type=="standard" :
        total+=instance.z*100
        return total
     else:
        return 0
</code></pre>

python django