Keyword arguments default to what you provide them in your function definition.
def some_method(param1="param1", param2=None):
# param1 is "param1" unless some other value is passed in.
# param2 is None if some value is not passed for it.
Consider:
def print_values(first_value="Hello", second_value=None):
print first_value, second_value or "World!"
print_values() #prints Hello World!
print_values(first_value="Greetings") #prints Greetings World!
print_values(second_value="You!") # prints Hello You!
print_values(first_value="Greetings", second_value="You!")
# prints Greetings You!
If you want to print the value of a local variable, you can do so by adding the expected variable name to your definition:
print first_value, special_variable_name or second_value or "World!"
Then, if you define a variable with that name:
special_variable_name = "Sean"
print_values() # prints Hello Sean
But don't do this -- it is unexpected, magic and definitely un-Pythonic -- pass the value you need in as your second parameter instead.
If you need to be able to call it with that variable without errors, then make sure to define that variable at the top of your module.
special_variable_name = None
# ... much code later ...
special_variable_name = "Sean" #This can be commented out
print_values(second_value=special_variable_name) # prints Hello Sean