I’m extracting a bunch of data from Salesforce via Python and the pip simple-salesforce package. To get to the objects I have to pass the object name to the function and I was wondering if there is a way to do that as a variable. What I do have right now is a bunch of functions with repeating code looking like this:
def foo(self, query):
data = selfsf.bulk.OBJECTNAME.query(query, lazy_operation=True)
What I’m trying to achieve should look like this:
def foo(self, OBJECT, query):
data = selfsf.bulk.OBJECT.query(query, lazy_operation=True)
I tried to do it via using the object name as basic argument but I just get a name error as an response. I also tried to set up the name as variable and get it via the getattr() function, which unfortunately didn’t work out.
Is there any way to do this? Thanks a lot 🙂
P. S. New to stackoverflow and an advanced beginner in python 🙂
Richard Pfeiffer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1