Skip to content

Introduction

DHV DHV v0.4.1  Source─────────────────────────────────────────────────── Disassembly──────────────────────────────────────────────  1  """The main application class."""0      0RESUME (149)  2  1      2LOAD_CONST (83)'The main    3  ######################################################application  4  # Python imports.class.'      5  fromargparseimportNamespace4STORE_NAME (114)__doc__      6  5      6LOAD_CONST (83)0            7  ######################################################8LOAD_CONST (83)('Namespac…  8  # Textual imports.10IMPORT_NAME (75)argparse     9  fromtextual.appimportInvalidThemeError12IMPORT_FROM (74)Namespace   10  14STORE_NAME (114)Namespace   11  ######################################################16POP_TOP (32) 12  # Textual enhanced imports.9      18LOAD_CONST (83)0           13  fromtextual_enhanced.appimportEnhancedApp20LOAD_CONST (83)('InvalidT… 14  22IMPORT_NAME (75)textual.app 15  ######################################################24IMPORT_FROM (74)InvalidThe… 16  # Local imports.26STORE_NAME (114)InvalidThe… 17  from.import__version__28POP_TOP (32) 18  from.dataimport(13     30LOAD_CONST (83)0           19  load_configuration, AST────────────────────────────────────────────────────── 20  update_configuration,Module 21  )body 22  from.screensimportMainExpr 23  value 24  Constant 25  ######################################################value 26  classDHV(EnhancedApp[None]):'The main application class.' 27  """The main application class."""kind 28  None 29  HELP_TITLE=f"DHV v{__version__}"ImportFrom 30  HELP_ABOUT=""" module 31      `DHV` is a terminal-based Python code explorer; it'argparse' 32      by and is maintained by [Dave Pearson](https://wwwnames 33      Free Software and can be [found on alias 34      GitHub](https://github.com/davep/dhv). name 35      """'Namespace' 36  HELP_LICENSE=""" asname  f1 Help  f10 Quit  ^n New  ^l Load ^p Commands

DHV is a Python code exploration tool for the terminal, designed to let you type in, load up, and edit Python code, and see what the resulting abstract syntax tree and bytecode looks like.

If you've ever felt curious about what your Python source code gets turned into, this is one tool that might help satisfy that curiosity.

Installation

Note

DHV requires Python 3.13 or later.

pipx

The application can be installed using pipx:

pipx install dhv

uv

The package can be install using uv:

uv tool install --python 3.13 dhv

Running DHV

Once you've installed DHV using one of the above methods, you can run the application using the dhv command.

Command line options

DHV has a number of command line options; they include:

-b, --bindings

Prints the application commands whose keyboard bindings can be modified, giving the defaults too.

dhv --bindings
ChangeCodeTheme - Change the theme of the Python code editor.
    Default: ctrl+f9
ChangeTheme - Change the application's theme
    Default: f9
Help - Show help for and information about the application
    Default: f1, ?
LoadFile - Load the content of a Python source file.
    Default: ctrl+l
NewCode - Empty the editor ready to enter some new code.
    Default: ctrl+n
Quit - Quit the application
    Default: f10, ctrl+q
ShowASTOnly - Only show the AST of the source code.
    Default: ctrl+t
ShowDisassemblyAndAST - Show both the disassembly and the AST of the source code.
    Default: ctrl+o
ShowDisassemblyOnly - Only show the disassembly of the source code.
    Default: ctrl+b
SwitchLayout - Switch the screen layout between horizontal and vertical.
    Default: f2
ToggleOffsets - Toggle the display of the offsets
    Default: f3
ToggleOpcodes - Toggle the display of the numeric opcodes
    Default: f4

-h, --help

Prints the help for the dhv command.

dhv --help
usage: dhv [-h] [-v] [--license] [-b] [-t THEME] [source]

DHV - A tool to dive into Python code.

positional arguments:
  source                A Python source file to disassemble

options:
  -h, --help            show this help message and exit
  -v, --version         Show version information
  --license, --licence  Show license information
  -b, --bindings        List commands that can have their bindings changed
  -t, --theme THEME     Set the theme for the application (set to ? to list
                        available themes)

v0.4.1

--license, --licence

Prints a summary of DHV's license.

dhv --license
DHV - A Python code explorer for the terminal.  
Copyright (C) 2025 Dave Pearson

This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.

-t, --theme

Sets DHV's theme; this overrides and changes any previous theme choice made via the user interface.

To see a list of available themes use ? as the theme name:

dhv --theme=?
catppuccin-latte
catppuccin-mocha
dracula
flexoki
gruvbox
monokai
nord
solarized-light
textual-dark
textual-light
tokyo-night

-v, --version

Prints the version number of DHV.

dhv --version
dhv v0.4.1

Getting help

A great way to get to know DHV is to read the help screen. Once in the application you can see this by pressing F1.

The DHV Help Screen DHV v0.4.1  Source─────────────────────────────────────────────────── Disassembly──────────────────────────────────────────────  1  """The mai Help ─────────────────────────────────────────────────────────────────────────────────  2  'The main    3  ##########application  4  # Python iclass.'      5  fromargpaDHV v0.4.1__doc__      6  0            7  ##########('Namespac…  8  # Textual argparse     9  fromtextuPython SourceNamespace   10  Namespace   11  ##########This panel is the Python source code that you're exploring. 12  # Textual 0           13  fromtextu('InvalidT… 14  Main application keys and commandstextual.app 15  ##########InvalidThe… 16  # Local imThe following key bindings and commands are available:InvalidThe… 17  from.imp 18  from.data0           19  load_cCommand                 KeyDescription                                         ('Enhanced… 20  update ───────────────────────────────────────────────────────────────────────────────── textual_en… 21  )Change Code Theme       ^f9Change the theme of the Python code editor.         EnhancedApp 22  from.screChange Theme            f9 Change the application's theme                      EnhancedApp 23  Help                    f1 Show help for and information about the application  24  Load File               ^l Load the content of a Python source file.           ─────────────── 25  ##########New Code                ^n Empty the editor ready to enter some new code.       26  classDHV(Quit                    f10Quit the application                                 27  """TheShow AST Only           ^t Only show the AST of the source code.                28  Show Disassembly And AST^o Show both the disassembly and the AST of the source  29  HELP_Tcode.                                                30  HELP_AShow Disassembly Only   ^b Only show the disassembly of the source code.        31      `DHV` Switch Layout           f2 Switch the screen layout between horizontal and      32      by andvertical.                                            33      Free SToggle Offsets          f3 Toggle the display of the offsets                    34      GitHubToggle Opcodes          f4 Toggle the display of the numeric opcodes            35      """ 36  HELP_L 37      DHV -  38  About 39      This p 40      under DHV is a terminal-based Python code explorer; it was created by and is maintained by 41      Softwa──────────────────────────────────────────────────────────────────────────────────────── 42      any la▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 43   Okay [Esc] 44      This p▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ 45      ANY WA──────────────────────────────────────────────────────────────────────────────────────── 46      FITNESS FOR A PARTICULAR PURPOSE. See the GNU Genemodule  f1 Help  f10 Quit  ^n New  ^l Load ^p Commands

The help will adapt to which part of the screen has focus, providing extra detail where appropriate.

The command palette

Another way of discovering commands and keys in DHV is to use the command palette (by default you can call it with ctrl+p or meta+x).

The DHV Command Palette DHV v0.4.1  Source─────────────────────────────────────────────────── Disassembly──────────────────────────────────────────────  1  """The main application class."""0      0RESUME (149)  2  ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔'The main    3  ##########application  4  # Python iSearch for commands…class.'      5  fromargpa__doc__      6  0            7  ##########Change Code Theme [^f9]('Namespac…  8  # Textual Change the theme of the Python code editor.argparse     9  fromtextuChange Theme [f9]Namespace   10  Change the application's themeNamespace   11  ##########Help [f1] 12  # Textual Show help for and information about the application0           13  fromtextuQuit [f10]('InvalidT… 14  Quit the applicationtextual.app 15  ##########Load File [^l]InvalidThe… 16  # Local imLoad the content of a Python source file.InvalidThe… 17  from.impNew Code [^n] 18  from.dataEmpty the editor ready to enter some new code.0           19  load_cSwitch Layout [f2]('Enhanced… 20  updateSwitch the screen layout between horizontal and vertical.textual_en… 21  )Toggle Offsets [f3]EnhancedApp 22  from.screToggle the display of the offsetsEnhancedApp 23  Toggle Opcodes [f4] 24  Toggle the display of the numeric opcodes─────────────── 25  ##########Show AST Only [^t] 26  classDHV(Only show the AST of the source code. 27  """TheShow Disassembly And AST [^o] 28  Show both the disassembly and the AST of the source code. 29  HELP_TShow Disassembly Only [^b] 30  HELP_AOnly show the disassembly of the source code. 31      `DHV` ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ 32      by and is maintained by [Dave Pearson](https://wwwkind 33      Free Software and can be [found on None 34      GitHub](https://github.com/davep/dhv). ImportFrom 35      """module 36  HELP_LICENSE=""" 'argparse' 37      DHV - A Python code explorer for the terminal.  \nnames 38  alias 39      This program is free software: you can redistributname 40      under the terms of the GNU General Public License 'Namespace' 41      Software Foundation, either version 3 of the Licenasname 42      any later version. None 43  level 44      This program is distributed in the hope that it wi0 45      ANY WARRANTY; without even the implied warranty ofImportFrom 46      FITNESS FOR A PARTICULAR PURPOSE. See the GNU Genemodule  f1 Help  f10 Quit  ^n New  ^l Load ^p Commands

Questions and feedback

If you have any questions about DHV, or you have ideas for how it might be improved, do please feel free to visit the discussion area and ask your question or suggest an improvement.

When doing so, please do search past discussions and also issues current and previous to make sure I've not already dealt with this, or don't have your proposed change already flagged as something to do.