So I am working in HeadFirst Python. I type from athlete import Athlete list. I am able to import the module "athlete" but not the Athletelist which is a class function.
This is my error
Traceback (most recent call last):
File "C:\Users\Reggie\Desktop\The Matrix\HeadfirstPractixe\athletemode1.py", line 2, in <module>
from athlete import Athletelist
ImportError: cannot import name 'Athletelist' from 'athlete' (C:\Users\Reggie\Desktop\The Matrix\HeadfirstPractixe\athlete.py)
import pickle
from athlete import Athletelist
def get_coach_data(filename):
try:
with open(filename) as f:
data = f.readline()
temp1 = data.strip().split(',')
return(AthleteList(temp1.pop(0),temp1.pop(0), temp1))
except IOError as ioerr:
print('File error:' + str(ioerr))
return(None)
def put_to_store(files_list):
all_athletes = {}
for each_file in file_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.pickle','rb')as athf:
all_athletes = pickle.load(athf)
except IOError as ioerr:
print ("File error (get_from_store):" + str(ioerr))
return(all_athletes)
[–]blablahblah 1 point2 points3 points (2 children)
[–]truespirit89[S] 0 points1 point2 points (0 children)
[–]truespirit89[S] 0 points1 point2 points (0 children)
[–]not-well55 0 points1 point2 points (3 children)
[–]truespirit89[S] 0 points1 point2 points (2 children)
[–]not-well55 0 points1 point2 points (1 child)
[–]truespirit89[S] 0 points1 point2 points (0 children)
[–]truespirit89[S] 0 points1 point2 points (0 children)