Python Forum
Keyword can't be an expression
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keyword can't be an expression
#1
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)
Reply
#2
you forgot to post your AthleteList function.
Reply
#3
Also this: temp1.d=pop(0). I'm not sure what that should be, maybe temp1.pop(0)?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find a specific keyword after another keyword and change the output sgtmcc 5 746 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Pass results of expression to another expression cmdr_eggplant 2 2,238 Mar-26-2020, 06:59 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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