2014-09-22 6 views
2

IPython은 object?을 REPL에 작성하여 편리한 객체 검사 도구를 제공합니다.IPython 개체 사용? in ipdb

ipdb에서 액세스 할 수 있습니까? 내장 명령으로 사용할 수없는 것 같습니다.

은 현재 내가 도움이 단지 표준 PDB 도움을주는 다음을 참조하십시오 IPython 쉘에서

ipdb> help 

Documented commands (type help <topic>): 
======================================== 
EOF bt   cont  enable jump pdef psource run  unt 
a  c   continue exit l  pdoc q  s  until 
alias cl   d   h  list pfile quit  step  up 
args clear  debug  help n  pinfo r  tbreak w 
b  commands disable ignore next pinfo2 restart u  whatis 
break condition down  j  p  pp  return unalias where 
+2

오브젝트 속성에 대한 코드에서이다'IPython.core.oinspect' (https://github.com/ipython/ipython/blob/master/IPython/core/oinspect.py). 'oinspect'에 대한'ipdb' 소스의 빠른 grep은 결과를 얻지 못하기 때문에'ipdb'에 노출되지 않은 것처럼 보입니다. –

답변

2

개체 검사는 문서화 문자열 및 기타 정보를 인쇄합니다. ipdb 디버거는 IPython 객체 검사의 일부인 문서화 문자열을 인쇄 할 수 있습니다. 다만 이것은 IPython에서 일어나는 것과 대부분의 방법은

In [5]: sum? 
Docstring: 
sum(iterable[, start]) -> value 

Return the sum of an iterable of numbers (NOT strings) plus the value 
of parameter 'start' (which defaults to 0). When the iterable is 
empty, return start. 
Type:  builtin_function_or_method 

In [6]: 

또 다른 쉘되어

ipdb> print(sum.__doc__) 
sum(iterable[, start]) -> value 

Return the sum of an iterable of numbers (NOT strings) plus the value 
of parameter 'start' (which defaults to 0). When the iterable is 
empty, return start. 
ipdb> 

내장 기능을 검사하기 위해 예를 들어

ipdb> print(object.__doc__) 

를 입력 대안은 IPython 셸을 디버그 중단 점으로 포함시키는 것입니다. 이것은 좋지만 그런 디버그 중단 점이 루프에 포함될 때 완전히 종료하는 방법을 찾지 못했습니다. 난 그냥 배운

from IPython import embed 
embed() # debug breakpoint 

더 좋은 방법은 약 을 사용하는 것입니다!을 ipdb에 넣으면, IPython 셸에서와 동일한 작업이 수행됩니다.

ipdb> !help(sum) 
Help on built-in function sum in module builtins: 

sum(iterable, start=0, /) 
    Return the sum of a 'start' value (default: 0) plus an iterable of numbers 

    When the iterable is empty, return the start value. 
    This function is intended specifically for use with numeric values and may 
    reject non-numeric types. 

ipdb>