To debug python code I use spyder from the anaconda distribution Am Mittwoch, 27. Januar 2021 schrieb C W <tmrs...@gmail.com>:
> Hi Michael, > Here's the code again, class should be called PERSONDatabase, misspelled > earlier: > class PERSONDatabase: > def __init__(self, id, created_at, name, attend_date, distance): > self._id = id > self.created_at = created_at > self.name= name > self.attend_date = attend_date > self.distance = distance > > @classmethod > def get_person(self, employee): > return PERSONDatabase(employee['created_at'], > employee['id'], > employee['name'], > employee['attend_date'], > employee['distance']) > > The PERSONDatabase class is called from main. This is the trace back I got > from the VS code: > > Traceback (most recent call last): > File "/Users/Mike/Documents/Mike/main.py", line 95, in <module> > main() > File "/Users/Mike/Documents/Mike/main.py", line 86, in main > args = get_feed() > File "/Users/Mike/DocumentsMike/main.py", line 32, in get_feed > result = [PERSONatabase.get_person(raw_person) for raw_neo in > raw_objects] > File "/Users/Mike/Documents/Mike/main.py", line 32, in <listcomp> > result = [NEODatabase.get_person(raw_person) for raw_neo in > raw_objects] > File "/Users/Mike/Documents/Mike/database.py", line 24, in get_person > return PERSONDatabase(person['created_at'], > KeyError: 'created_at' > > Thank you very much! > > On Wed, Jan 27, 2021 at 12:10 AM Michael Torrie <torr...@gmail.com> wrote: > > > On 1/26/21 8:37 PM, C W wrote: > > > I have a naive question. How do I use traceback or trace the stack? In > > > particular, I'm using VS Code with Python interactive console. > > > > Show us the traceback here and we can help you interpret it. Copy and > > paste it from the VS Code console. > > > > > Say, I want to print the value of employee['name']. Can I do it? > > > > Yes I would think so. > > > > > My understanding is that these classes are just "skeletons". I must > > > create an instance, assign values, then test? > > > > Can't you just do something like this? > > > > class NEODatabase: > > def __init__(self, id, created_at, name, attend_date, distance): > > self._id = id > > self.created_at = created_at > > self.name = name > > self.attend_date = attend_date > > self.distance = distance > > > > @classmethod > > def get_person(self, employee): > > print (employee['name']) > > > > return PERSONDatabase(employee['created_at'], > > employee['id'], > > employee['name'], > > employee['attend_date'], > > employee['distance']) > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 -- https://mail.python.org/mailman/listinfo/python-list