Skip to content

Instantly share code, notes, and snippets.

@hamaguchi-amago
Created July 8, 2021 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamaguchi-amago/77b5304fa6cf0c3ac2e0fe063d8dbd1e to your computer and use it in GitHub Desktop.
Save hamaguchi-amago/77b5304fa6cf0c3ac2e0fe063d8dbd1e to your computer and use it in GitHub Desktop.
動的な引数の渡し方のサンプル
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)
@hamaguchi-amago
Copy link
Author

ブログの記事で作成しました。
興味のある方はご覧ください。

【Python】引数を動的に渡す方法
https://neko-py.com/python-param-dynamic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment