0

I am trying to break my Python script into multiple .py files. In sf_opps.py file I have all the login credentials and a query that fetches the data with REST API call. The data is stored in sf_prod_data variable. How can I access this variable that contains the data I need from another .py file?

I need to loop through the sf_prod_data and I don't want to use classes as all of my code are mostly loops, so need to know how to access the variables with stored data in it from different .py files.

I have tried:

import sf_opps
print(sf_prod_data)

sf_prod_data is Undefined

1
  • 1
    try print(sf_opps.sf_prod_data) Commented May 19, 2020 at 17:58

1 Answer 1

1

Either:

from sf_opps import sf_prod_data
print(sf_prod_data)

or:

import sf_opps
print(sf_opps.sf_prod_data)

Further reading: python tutorial on modules

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @causaSui

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.