Python Forum
How can I link these 6 routines to run sequentially?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I link these 6 routines to run sequentially?
#1
Every week I have to insert scores for 7 classes, so I am trying to automate this as much as possible.

I now have 6 routines which all work in my idle3 shell and in a bash terminal in Ubuntu 18.04 and do everything I need.

The routines are:

copyOldData
insert3Cols
getScoresInsertScores
calculatePercentScores
paintColumnsYellow
insertPhotos

The last one puts the photos back, because openpyxl does not load images.

I want to put these all in one program. None of these routines take any parameters, they just do their job and finish with
print('All done')

I thought I could define each routine as a function:

def copyOldData()
mycode ...
def insert3Cols()
mycode ...
def getScoresInsertScores()
mycode ...
def calculatePercentScores()
mycode ...
def paintColumnsYellow()
mycode ...
def insertPhotos()
mycode ...

Then define main()
def main()
copyOldData()
insert3Cols()
getScoresInsertScores()
calculatePercentScores()
paintColumnsYellow()
insertPhotos()

Then just write:

go = main()

But this does not work, it stops at

Quote:pedro@pedro-newssd:~/insertScores/python$ ./allStepsIn1.py
File "./allStepsIn1.py", line 6
def copyOldData
^
SyntaxError: invalid syntax
pedro@pedro-newssd:~/insertScores/python$

What is the best way to link these 6 routines to run sequentially?
Reply
#2
just create a function that calls the others in succession
def call_all():
    copyOldData()
    insert3Cols()
    ...
Reply
#3
Thank you very much! Worked in a split second, like a dream!! When I think of all the time I spent copying and pasting before!!

I forgot the : after def function()

That was the problem!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Are list/dict comprehensions interpreted really sequentially? anata2047 3 1,450 May-31-2022, 08:43 PM
Last Post: Gribouillis
  How to call multiple functions sequentially Mayo 2 9,328 Jan-06-2021, 07:37 PM
Last Post: Mayo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020