Background:
I'm creating a report that gets sent out to various users in the organization.
I have 3 separate files to do this.
The solution works fine, however it just keeps producing the same file over and over again for the last user in the list.The variable that is being saved is only the last one being executed. It should be producing a different file for each user. I'm not sure if this a nested loop issue, but see below for more context:
File 1) subscribers.py - a list of emails:
subscriber_list = ['abe@gmail.com','obama@gmail.com','clinton@gmail.com']
File 2) start.py - loops through subscribers to execute third file:
import subscribers
for user in subscribers.subscriber_list :
login_input = user
exec(open('produce_report.py').read())
File 3) produce_report.py - runs through a series of logic based on login_input, for simplicity I'm just going to print the value.
import subscribers
import start
login_input = start.login_input
print (start.login_input)
Expected Result:
- abe@gmail.com
- obama@gmail.com
- clinton@gmail.com
Result I'm getting:
- clinton@gmail.com
- clinton@gmail.com
- clinton@gmail.com