Python Forum

Full Version: Keyword can't be an expression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
you forgot to post your AthleteList function.
Also this: temp1.d=pop(0). I'm not sure what that should be, maybe temp1.pop(0)?