Home > Net >  how to pass every key and value of dict as arguments to other function in python
how to pass every key and value of dict as arguments to other function in python

Time:11-08

def set_detail_to_user(id, key, val):
    """
    Set details to id@domain by admin
    """

    tx = iroha.transaction([iroha.command('SetAccountDetail',
                account_id=id  '@'   domain_name, key=key, value=val)
            ])
    IrohaCrypto.sign_transaction(tx, ADMIN_PRIVATE_KEY)
    send_transaction_and_print_status(tx)
  • now I want to pass a dict as arg when I call this function
#now when i call the function
user = new.__id.replace('-', '')
my_dict = new.__dict__
set_detail_to_user(user,every_key_in_my_dict, every_value_in_my_dict)

any suggestions please to call the function multiple times for each key-value pair

CodePudding user response:

for key, value in dict.items():
        set_detail_to_user(id, key, value)

There are multiple ways. You can pass whole dictionary too.

  • Related