DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Get started with Python type hints
Otmane Riad
Otmane Riad

Posted on

Get started with Python type hints

Python is best thought of as a โ€œdynamic, but strongly typedโ€ language. Types arenโ€™t associated with the names for things, but with the things themselves.

This makes Python flexible and convenient for developers, because you donโ€™t have to rigorously define and track variable types if youโ€™re just throwing together a quick-and-dirty script. But for bigger projects, especially libraries used by third parties, it helps to know which object types are associated with which variables.

For some time now, Python has had the ability to โ€œannotateโ€ names with type information, in one form or another. With Python 3.5, type hints officially became part of the language (PEP 484). Using a linter or code-checking tool, developers can check the consistency of variables and their types across a code base, and perform static analyses of code that would previously have been difficult or impossible. All this is done ahead of time, before the code runs.

In this article weโ€™ll explore some basic examples of Python type hinting. But first weโ€™ll clear up a common misunderstanding about what it is and isnโ€™t used for.

Read More: https://hitechnoloy.ca/get-started-with-python-type-hints/

Top comments (2)

Collapse
 
aatmaj profile image
Aatmaj

Good post.

Collapse
 
nexteventideas profile image
Otmane Riad Author

thank you sir

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. ๐Ÿ›