0
votes

I have the following function declaration:

def set_data(obj=None, name='delp', type=None):

Is there a python shortcut, where type is equal with 'name' value(default r passed) if is None ?

1
Don't use reserved words, for your own sake (and probably everyone else working with your code), please :) - han solo

1 Answers

4
votes

The usual idiom is:

def set_data(obj=None, name='delp', type=None):
    if type is None:
        type = name

(But don't actually use type as a variable name, it'll mask the built in function as described here: Is it safe to use the python word "type" in my code?)