---
title: "Discussion on \"Exposing the package version defined in the pyproject.toml as a __version__ variable\" | Hashnode"
description: "Discussion on \"Exposing the package version defined in the pyproject.toml as a __version__ variable\". By convention, Python packages expose their version through a __version__ variable:\n>>> import package\n>>> package.__version__\n0.4.2\n\nIdeally, the package version should be defined in one place only. Typical approaches include hardcoding it in the pa..."
url: "https://hashnode.com/posts/exposing-the-package-version-defined-in-pyprojecttoml-as-a-version-variable/664f2f335d5eb2edd08bac32"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Exposing the package version defined in the pyproject.toml as a \_\_version\_\_ variable](https://pragmaticnotes.hashnode.dev/exposing-the-package-version-defined-in-pyprojecttoml-as-a-version-variable?utm_source=hashnode&utm_medium=feed)

By convention, Python packages expose their version through a \_\_version\_\_ variable: >>> import package >>> package.\_\_version\_\_ 0.4.2 Ideally, the package version should be defined in one place only. Typical approaches include hardcoding it in the pa...

May 23, 2024 · 2 min read · pragmaticnotes.hashnode.dev  
Updated May 24, 2024  
Read the article

-   [#hatch](https://hashnode.com/tag/hatch)
-   [#python](https://hashnode.com/tag/python)
-   [#poetry](https://hashnode.com/tag/poetry)
-   [#python-poetry](https://hashnode.com/tag/python-poetry)
-   [#packaging](https://hashnode.com/tag/packaging)
-   [#pypi](https://hashnode.com/tag/pypi)

## Written by

[Kilian Kluge](https://hashnode.com/@ionicsolutions)

@ionicsolutions

  
[View profile](https://hashnode.com/@ionicsolutions)

My journey into software and infrastructure engineering started in a physics research lab, where I discovered the merits of loose coupling and adherence to standards the hard way. I like automated testing, concise documentation, and hunting complex bugs.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
