Thanks to visit codestin.com
Credit goes to github.com

Skip to content

%psource #613

Closed
Closed
@norvig

Description

@norvig

We use %psource in notebooks to refer to code, and that is good. But the code is displayed in a popup window, and one drawback is that you can only display one function at a time this way. Another drawback is that the code doesn't scroll with the rst of the document (this can sometimes be an advantage, sometimes a drawback).

I propose to add to utils the following function, and prefer to use it over %psource:

import inspect

def psource(*functions):
    "Print the source code for the given function(s)."
    print('\n\n'.join(inspect.getsource(fn) for fn in functions))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions