
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
Pytree is a Node.js package that prints a tree of a Python project's directory structure with classes and methods. It provides an API that allows you to extract the classes and methods from your Python files, and then prints or saves a tree structure of your project's directory with those extracted classes and methods.
import { runParse } from 'pytree';
// Print the tree structure of the current directory
const structure = runParse();
console.log(structure)
// [{ level: 0, type: 'file', name: 'file1.py' },
// { level: 1, type: 'class', name: 'MyClass' },
// { level: 2, type: 'method', name: 'my_method' },
// { level: 2, type: 'method', name: 'method_and_child' }]
// Print the tree structure of the directory 'src'
runParse(['src']);
// Print the tree structure of the directories 'src' and 'tests',
// excluding any files or directories that match the regular expression /__pycache__/
runParse(['src', 'tests'], null, [/__pycache__/]);
└─> file1.py
└─> MyClass
└─> my_method
└─> MyOtherClass
└─> my_other_method
npm install pytree
or
yarn add pytree
The runParse() function is the main entry point for the package. It takes the following arguments:
dirs (optional, default=['.']): an array of directories/files to search for Python files.outputFile (optional): a file path to save the output to. If this argument is not provided, the output is printed to the console.except (optional, default=[]): an array of regular expressions to exclude files or directories.npx pytree
npx pytree --dir /path/to/directory1 /path/to/file /path/to/directory2
npx pytree --except "__init__.py" "test_*"
npx pytree --dest /path/to/output.txt
FAQs
Print python project tree structure with classes and methods
We found that pytree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.