Python Forum

Full Version: How can I link these 6 routines to run sequentially?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
just create a function that calls the others in succession
def call_all():
    copyOldData()
    insert3Cols()
    ...
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!