I am returning a variable from a function in python.
When I try to retrieve the variable in another function, it prints out the print statements of the original function for a second time.
Here is my code:
user_name = 'my_user'
kms_cleint = 'client_info'
aws_account = 'company-account'
def create_kms_key(user_name, kms_client):
print("****************************************************************")
print(" Create KMS Key for %s " % user_name)
print("****************************************************************")
kms_key_id = 5
return kms_key_id
def store_secret(user_name, kms_client, secrets_client, aws_account):
print("****************************************************************")
print(" Store Secret for %s for AWS account: %s " % (user_name, aws_account))
print("****************************************************************")
f = open(os.devnull,"w")
kms_key_id = create_kms_key(user_name, kms_client).set_log_stream(f)
My output:
****************************************************************
Create KMS Key for user35
****************************************************************
****************************************************************
Store Secret for user35 for AWS account: company-account
****************************************************************
****************************************************************
Create KMS Key for user35
****************************************************************
I am trying to avoid printing out the create_kms_key function output a second time.
I am getting this error when I try to redirect the output to /dev/null when I call the create_kms_key function:
AttributeError: 'int' object has no attribute 'set_log_stream'
How can I keep the create_kms_key function from printing it's output a second time?