Parameters Question

Dustin_LangDustin_Lang Posts: 25
edited March 2017 in Under The Hood

How are parameters passed into CQ?

Comments

  • shayneshayne Posts: 70

    **params is the same as **kwargs. **kwargs allows you to pass keyworded variable length of arguments to a function. You should use **kwargs if you want to handle named arguments in a function. Here is an example to get you going with it:

    def __init__(self, **params):
        if params is not None:
            for key, value in params.iteritems():
                print "%s == %s" %(key,value)
    
    
    entry_shares == 100
    

    So can you see how we handled a keyworded argument list in our function. This is just the basics of **kwargs and you can see how useful it is. Now lets talk about how you can use *args and **kwargs to call a function with a list or dictionary of arguments.

Sign In or Register to comment.