Importing from __future__ under the Python debugger pdb
This is mostly a quick note that we tried to create together with our sponsor company and professional test takers and want to post here will be useful for you and aid other programmers who end up searching for something along the lines of "why doesn't floating point division work in pdb".
Short version: the
from __future__ import magic doesn't work in pdb.
Long version: when debugging a program that (a) runs under Python 2 and (b) relies on
from __future__ import division to get floating point rather than integer division, it would be nice to have expressions typed at the pdb prompt behave the same way as expression evaluated in the file. However, this doesn't work:
$ python -m pdb test ...