Skip to content

%psource #613

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy