Created
July 8, 2021 06:02
-
-
Save hamaguchi-amago/77b5304fa6cf0c3ac2e0fe063d8dbd1e to your computer and use it in GitHub Desktop.
動的な引数の渡し方のサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def function( | |
param1='default1', | |
param2='default2', | |
param3='default3', | |
): | |
print(f"param1:{param1}") | |
print(f"param2:{param2}") | |
print(f"param3:{param3}") | |
print('-' * 10) | |
function(param1='new1', param2='new2', param3='new3') | |
print('-' * 10) | |
function(param1='new1', param2='new2') | |
print('-' * 10) | |
param_dict = {'param1': 'new1', | |
'param2': 'new2', | |
'param3': 'new3'} | |
function(**param_dict) | |
print('-' * 10) | |
param_dict = {'param1': 'new1', | |
'param2': 'new2'} | |
function(**param_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログの記事で作成しました。
興味のある方はご覧ください。
【Python】引数を動的に渡す方法
https://neko-py.com/python-param-dynamic