خرید بک لینک

Vote count: 0

I created a function and I would like to be able to call it with a set of keyworded-parameters that I called '**criterias':

def actionBasedOnParameters(**criterias):
    # my code

Inside this set of parameters one of them will be called 'SumInc' and I would like to pass on a range to it. A range that will be of the form of [1:15] or [1:] or [:15]. Something that will essentially let me check whether a variable in my code is greater than a certain boundary or lower than another boundary or both. In the same way, as these lines of codes do:

In [188]: 1 <= 15.98877 <= 15
Out[188]: False

In [188]: 1 <= 15.98877 
Out[188]: True

In [188]: 15.98877 <= 15
Out[188]: False

But I am looking for a neater way to pass both boundaries without having to create a parameter for each and many if conditions to get to where I want to.

Something that would like this:

In [189]: criterias = dict(SumInc=[:14])

def actionBasedOnParameters(**criterias):
    if criterias['SumInc'] is not None:
        if my_variable is in criterias['SumInc']:
            #action1
        else:
            #action2

Is there something of this kind existing?

Thanks for your tips,

asked 25 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 18 مرداد 1395 ساعت: 23:18

صفحه بندی