Hacker News new | past | comments | ask | show | jobs | submit login

There’s the help() function as well! Super helpful!



And if you use IPython, you can use the ? shorthand, too:

    In [1]: int?
    Init signature: int(self, /, *args, **kwargs)
    Docstring:
    int([x]) -> integer
    int(x, base=10) -> integer

    Convert a number or string to an integer, or return 0 if no arguments
    are given.  If x is a number, return x.__int__().  For floating point
    numbers, this truncates towards zero.

    [...]


Favorite way to develop python, so far:

1. Write the program skeleton

2. Put an import pdb; pdb.set_trace() whereever I need to fill out next

3. Once I hit the breakpoint, type 'interact'

4. Start coding in the debugger.

4a. For small functions write in a scratch pad, test against another python console, then paste into the current debugger.

4b. For network calls, save the inputs and outputs. Toss a decorator on some functions to log the inputs and outputs to files, and cool we already have some proto test data.

4c. For documentation, call help() on the variable or method or module.


the double questionmark `foo??` is sometimes also useful, since it'll show full source for the function/method/thing if you do it to a function.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: