Python Forum
Keyword can't be an expression - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Keyword can't be an expression (/thread-22301.html)



Keyword can't be an expression - fcktheworld587 - Nov-06-2019

In the following module, IDLE refuses to run it, siting "Keyword can't be an expression" and highlights the ( on the righthand side of AthleteList inside the get_coach_data function. What am I doing wrong? Edit: pycharm will run it with exit status 0
return(AthleteList(temp1.d=pop(0), temp1.pop(0), temp1))
the following is the full module
import pickle
from athletelist import AthleteList


def get_coach_data(filename):
    try:
        with open(filename) as f:
            data = f.readline()
            temp1 = data.strip().split(",")
            return(AthleteList(temp1.d=pop(0), temp1.pop(0), temp1))
    except Exception as ioerr:
        print("File error:" + str(ioerr))
        return(None)

def put_to_store(files_list):
    all_athletes = {}
    for each_file in files_list:
        ath = get_coach_data(each_file)
        all_athletes[ath.name] = ath
    try:
        with open('athletes.pickle', 'wb') as athf:
                  pickle.dump(all_athletes, athf)
    except IOError as ioerr:
                  print('File Error(put_and_store):' + str(ioerr))
    return(all_athletes)

def get_from_store():
                all_athletes = {}
                try:
                      with open('athletes.picle', 'rb') as athf:
                          all_athletes = pickle.load(athf)
                except IOError as ioerr:
                      print('File error (get_from_store) ' + str(ioerr))
                return(all_athletes)



RE: Keyword can't be an expression - MckJohan - Nov-06-2019

you forgot to post your AthleteList function.


RE: Keyword can't be an expression - ichabod801 - Nov-07-2019

Also this: temp1.d=pop(0). I'm not sure what that should be, maybe temp1.pop(0)?