[IPython-dev] making pdoc, pdef, and pinfo more generally useful (Was Re: Patches to use pydb instead of pdb for debugging)

R. Bernstein rocky at panix.com
Thu Oct 12 07:46:20 EDT 2006


Ville M. Vainio writes:
 > On 10/12/06, R. Bernstein <rocky at panix.com> wrote:
 > 
 > >     def do_pinfo(self, arg):
 > >         """The debugger (or any application) equivalant of ?obj"""
 > >         namespaces = [('Locals', self.curframe.f_locals),
 > >                       ('Globals', self.curframe.f_globals)]
 > 
 > Any particular reasons for using tuple for namespaces instead of
 > separate kwargs?


I'm not sure exactly what you mean. If you mean use:

        __IPYTHON__.magic_pinfo("pinfo %s" % arg, 
	                        namespaces=[('Locals', self.curframe.f_locals),
                      ('Globals', self.curframe.f_globals)])
rather than:
        namespaces = [('Locals', self.curframe.f_locals),
                      ('Globals', self.curframe.f_globals)]
        __IPYTHON__.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)

I find the latter a little easier to read because it is less
cluttered. This kind of stuff reminds me of similar discussions among
C programmers of between using:
    if ( 'x' == c=getc() )
versus:
    c=getc()
   if ( 'x' == c )

Which variant is used is a matter of style. Although some style guides
recommend the latter, especially when the assignment is more complex,
many folks prefer the former. Personally, I really don't care (in both
C or Python).

If you mean something else, I don't doubt there may be cleverer ways
to do what I want: allow Magic._ofind to get passed a namespace
parameter -- currently an indirect call from magic_pinfo() via
_inspect() -- so that _ofind uses the supplied namespaces known by
do_pinfo() instead of the current hard-coded values which make sense
only in a shell.

So if you could just make the change, however you want to do it, that
would be great! Then debuggers (pdb and pydb) and other similar kinds
of applications would then have access to more of the good stuff from
ipython.

And speaking of changes how are the first set of patches coming along?
If I recall correctly you said last Tuesday you might look at.. :-)

Thanks.



More information about the IPython-dev mailing list