Daniel Ezekiel Daniel Ezekiel -3 years ago 101
Python Question

How to get the return values from a function?

I am working on a function to get the information from the database so I can get the return values. I am trying to find out how to get each value from the

function at a time.

When I try this:

def UpdateEpg(self, program_title = '', program_start = '', program_stop = ''):
conn = database.connect(self.profilePath)
cur = conn.cursor()
cur.execute("SELECT title, start_date, stop_date FROM programs where channel=? LIMIT 2", [channel])
program = cur.fetchall()

for ind, row in enumerate(program):
program_title = row[0]
program_start_date = str(row[1])
program_stop_date = str(row[2])

return program_title, program_start_date, program_stop_date

print self.UpdateEPG(program_title)
print self.UpdateEPG(program_start_date)
print self.UpdateEPG(program_stop_date)

It will not let me to get the single value from
. I want to get the single value so I could input in the object to set the label. Can you show me an example how I could get
for each variable to get access to
to get the information I am looking for?

Answer Source

accessing multiple values is similar to returning multiple values. Just put the names on the left side of =

program_title, program_start_date, program_stop_date = self.UpdateEpg()
print program_title
print program_start_date
print program_stop_date
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download