wesm / pydata-book

Materials and IPython notebooks for "Python for Data Analysis" by Wes McKinney, published by O'Reilly Media
Other
22.27k stars 15.19k forks source link

The problem of chapter B5.1 #201

Open MaxforCherubim opened 7 months ago

MaxforCherubim commented 7 months ago

The code is wrong.

from IPython.core.debugger import Pdb

def set_trace():
    Pdb(.set_trace(sys._getframe().f_back)

def debug(f, *args, **kwargs):
    pdb = Pdb()
    return pdb.runcall(f, *args, **kwargs)

It should be

from IPython.core.debugger import Pdb
import sys

def set_trace():
        Pdb.set_trace(sys._getframe().f_back)

def debug(f, *arg, **kwargs):
        pdb = Pdb()
        return pdb.runcall(f, *args, **kwargs)

But even the code get repaired, there still exist a AttributeError AttributeError: 'frame' object has no attribute 'initial_frame'

wesm commented 4 months ago

Thanks -- I will have a closer look at updating this for the latest version of Python