2/5
## Section Headers in Vyper We've learned about how to format our Vyper code with tools such as `black` and `ruff`. However, when our code grows, it can become difficult to navigate and understand. Section headers help with this. Section headers help us organize our code and separate it into different sections. For instance, we can separate the **Imports**, **State Variables**, and **Functions** sections to make our code easier to read and understand. There are two main ways to create section headers: - Using `vheader` Python package - Using `headers-vy` Rust package ## `vheader` Python Package We can use the `vheader` Python package to generate section headers in our Vyper code. Let's look at how to install this package. First, we go to the repository's `README` file. Then, we copy the following command to install `vheader`: ```bash uv tool install vheader ``` Once installed, we can run the following command in our terminal: ```bash vheader imports ``` This command will generate a section header for the **Imports** section in our Vyper code. We can do the same for other sections: ```bash vheader state variables ``` ```bash vheader functions ``` This will add section headers to the **State Variables** and **Functions** sections. ## `headers-vy` Rust Package There is also the `headers-vy` Rust package that we can install. To install `headers-vy`, we need to make sure Rust and Cargo are installed on our machine. The `README` file has instructions for installing those if needed. Once we have Rust and Cargo installed, we can clone the `headers-vy` repository and run the following command in our terminal to install the package: ```bash cargo install --path . ``` Once the package is installed, we can run the following command in our terminal: ```bash ./headers-vy "testing 123" ``` This command will generate the following header: ```bash # ################################################## # # # TESTING 123 # # # # ################################################## ``` ## Conclusion Adding section headers to our Vyper code can significantly improve readability and organization. By separating our code into distinct sections, we can make it easier to navigate and understand, ultimately leading to more maintainable and efficient code.
A practical guide to using Vheader for formatting code in your Vyper projects - Vheader is a tool that can help you automatically format your Vyper code, creating clear and consistent headers and sections that make your codebase much more readable. Vheader is available in Python and Rust.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Duration: 2h 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar