TypeError: 'module' object is not callable

Custom class, save as Athlete.py file

class Athlete:

def __init__(self, a_name, a_dob=None, a_times=[]):

self.name = a_name

self.dob = a_dob

self.times = a_times

Called in IDLE

>>> import Athlete

>>> sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])

Report the following error:

Traceback (most recent call last):

  File "<pyshell#2>", line 1, in <module>

    sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])

TypeError: 'module' object is not callable

Reason, no path to import class

import Athlete

sarah = Athlete.Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])

or

from Athlete import Athlete

sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326856514&siteId=291194637