How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

C W tmrsg11 at gmail.com
Wed Jan 27 13:42:56 EST 2021


For learning purposes, here's the files:
https://www.dropbox.com/sh/a3iy40rcvib4uvj/AAADmlM2i6NquWC1SV0nZfnDa?dl=0

Yes, you are correct about "employee" and "person" discrepancies. For now,
the list comprehension is where I get stuck.

I'd like to know how the experts on here are approaching and debugging
this.

Bonus if no debugger or breakpoint. Just the good ol' run the function and
evaluate/print output for problems.

Thanks so much,

Mike

On Wed, Jan 27, 2021 at 10:53 AM Michael Torrie <torriem at gmail.com> wrote:

> On 1/26/21 10:19 PM, C W wrote:
> > 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'
>
> The actual error is the last part, which is a KeyError on line 24.  A
> key error usually is from a dictionary-like object and it means the
> requested key is not found in that object.  In other words, this person
> object has no "created_at" key.  Hope that makes sense.
>
> I do not know why the code you posted refers to "employee" but the
> traceback refers to "person."
>
> In any case the trace back shows you what called what until the error
> occurred. You can trace the execution of the code simply by following
> it.  main() called get_feed() which set up a list comprehension, which
> calls get_person() which is where the error is occurring.  I'm not
> following the list comprehension stuff; I don't know why python is first
> referring to PERSONatabase and then refers to NEODatabase.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list