Are you taking full advantage of Python 3?

Are you sure?

Here are 10 Python 3 features that will change the way you are writing code today.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
More information about enumerations:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://docs.python.org/3.4/library/enum.html
https://docs.python.org/3.4/libra... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://pythonspot.com/python-enum/ 

https://pythonspot.com/python-en... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="2⃣" title="Tastenkappe Ziffer 2" aria-label="Emoji: Tastenkappe Ziffer 2"> Data classes - Python 3.7+

Using data classes, Python will automatically generate special methods like "_init__" and "__repr__", reducing a lot of the clutter from your code.

This considerably reduces the amount of repetitive code that you had to write before.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable= Data classes - Python 3.7+Using data classes, Python will automatically generate special methods like "_init__" and "__repr__", reducing a lot of the clutter from your code.This considerably reduces the amount of repetitive code that you had to write before.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="2⃣" title="Tastenkappe Ziffer 2" aria-label="Emoji: Tastenkappe Ziffer 2"> Data classes - Python 3.7+Using data classes, Python will automatically generate special methods like "_init__" and "__repr__", reducing a lot of the clutter from your code.This considerably reduces the amount of repetitive code that you had to write before.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about data classes:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://realpython.com/python-data-classes/
https://realpython.com/python-da... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://docs.python.org/3/library/dataclasses.html

https://docs.python.org/3/library... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="3⃣" title="Tastenkappe Ziffer 3" aria-label="Emoji: Tastenkappe Ziffer 3"> Pathlib - Python 3.4+

The pathlib module provides a way to interact with the file system in a much more convenient way than dealing with os.path or the glob module.

The pathlib module makes everything simpler. When I discovered it, I& #39;ve never looked back.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable= Pathlib - Python 3.4+The pathlib module provides a way to interact with the file system in a much more convenient way than dealing with os.path or the glob module.The pathlib module makes everything simpler. When I discovered it, I& #39;ve never looked back. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="3⃣" title="Tastenkappe Ziffer 3" aria-label="Emoji: Tastenkappe Ziffer 3"> Pathlib - Python 3.4+The pathlib module provides a way to interact with the file system in a much more convenient way than dealing with os.path or the glob module.The pathlib module makes everything simpler. When I discovered it, I& #39;ve never looked back. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about the pathlib module:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://realpython.com/python-pathlib/ 
https://realpython.com/python-pa... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://docs.python.org/3/library/pathlib.html

https://docs.python.org/3/library... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="4⃣" title="Tastenkappe Ziffer 4" aria-label="Emoji: Tastenkappe Ziffer 4"> Type hints - Python 3.5+

You can use type hints to indicate the type of a value in your code. For example, you can use it to annotate the arguments of a function and its return type.

These hints make your code more readable, and help tools understand it better.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable= Type hints - Python 3.5+You can use type hints to indicate the type of a value in your code. For example, you can use it to annotate the arguments of a function and its return type.These hints make your code more readable, and help tools understand it better. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="4⃣" title="Tastenkappe Ziffer 4" aria-label="Emoji: Tastenkappe Ziffer 4"> Type hints - Python 3.5+You can use type hints to indicate the type of a value in your code. For example, you can use it to annotate the arguments of a function and its return type.These hints make your code more readable, and help tools understand it better. https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about type hints:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> http://veekaybee.github.io/2019/07/08/python-type-hints/
https://veekaybee.github.io/2019/07/0... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://docs.python.org/3/library/typing.html

https://docs.python.org/3/library... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="5⃣" title="Tastenkappe Ziffer 5" aria-label="Emoji: Tastenkappe Ziffer 5">f-strings - Python 3.6+

Instead of having to use the .format() method to print your strings, you can use f-strings for a much more convenient way to replace values in your strings.

f-strings are much more readable, concise, and easier to maintain.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable=f-strings - Python 3.6+Instead of having to use the .format() method to print your strings, you can use f-strings for a much more convenient way to replace values in your strings.f-strings are much more readable, concise, and easier to maintain.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="5⃣" title="Tastenkappe Ziffer 5" aria-label="Emoji: Tastenkappe Ziffer 5">f-strings - Python 3.6+Instead of having to use the .format() method to print your strings, you can use f-strings for a much more convenient way to replace values in your strings.f-strings are much more readable, concise, and easier to maintain.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about f-strings:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://realpython.com/python-f-strings/
https://realpython.com/python-f-... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.python.org/dev/peps/pep-0498/

https://www.python.org/dev/peps/... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="6⃣" title="Tastenkappe Ziffer 6" aria-label="Emoji: Tastenkappe Ziffer 6">Extended Iterable Unpacking - Python 3.0+

Using this trick, while unpacking an iterable, you can specify a "catch-all" variable that will be assigned a list of the items not assigned to a regular variable.

Simple, but very convenient to keep the code concise.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable=Extended Iterable Unpacking - Python 3.0+Using this trick, while unpacking an iterable, you can specify a "catch-all" variable that will be assigned a list of the items not assigned to a regular variable.Simple, but very convenient to keep the code concise.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="6⃣" title="Tastenkappe Ziffer 6" aria-label="Emoji: Tastenkappe Ziffer 6">Extended Iterable Unpacking - Python 3.0+Using this trick, while unpacking an iterable, you can specify a "catch-all" variable that will be assigned a list of the items not assigned to a regular variable.Simple, but very convenient to keep the code concise.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about Extended Iterable Unpacking:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.python.org/dev/peps/pep-3132/
https://www.python.org/dev/peps/... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.rfk.id.au/blog/entry/extended-iterable-unpacking/

https://www.rfk.id.au/blog/entr... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="7⃣" title="Tastenkappe Ziffer 7" aria-label="Emoji: Tastenkappe Ziffer 7">Walrus operator - Python 3.8+

Using assignment expressions (through the walrus operator :=) you can assign and return a value in the same expression.

This operator makes certain constructs more convenient and helps communicate the intent of your code more clearly.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable=Walrus operator - Python 3.8+Using assignment expressions (through the walrus operator :=) you can assign and return a value in the same expression. This operator makes certain constructs more convenient and helps communicate the intent of your code more clearly.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="7⃣" title="Tastenkappe Ziffer 7" aria-label="Emoji: Tastenkappe Ziffer 7">Walrus operator - Python 3.8+Using assignment expressions (through the walrus operator :=) you can assign and return a value in the same expression. This operator makes certain constructs more convenient and helps communicate the intent of your code more clearly.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about the Walrus operator:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://deepsource.io/blog/python-walrus-operator/
https://deepsource.io/blog/pyth... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.python.org/dev/peps/pep-0572/

https://www.python.org/dev/peps/... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="8⃣" title="Tastenkappe Ziffer 8" aria-label="Emoji: Tastenkappe Ziffer 8">Async IO - Python 3.4+

The asyncio module is the new way to write concurrent code using the async and await syntax.

This approach allows for much more readable code and abstracts away many of the complexity inherent with concurrent programming.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable=Async IO - Python 3.4+The asyncio module is the new way to write concurrent code using the async and await syntax.This approach allows for much more readable code and abstracts away many of the complexity inherent with concurrent programming.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="8⃣" title="Tastenkappe Ziffer 8" aria-label="Emoji: Tastenkappe Ziffer 8">Async IO - Python 3.4+The asyncio module is the new way to write concurrent code using the async and await syntax.This approach allows for much more readable code and abstracts away many of the complexity inherent with concurrent programming.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about the asyncio module:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://realpython.com/async-io-python/
https://realpython.com/async-io-... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://docs.python.org/3/library/asyncio.html

https://docs.python.org/3/library... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="9⃣" title="Tastenkappe Ziffer 9" aria-label="Emoji: Tastenkappe Ziffer 9">Underscores in Numeric Literals - Python 3.6+

This one is a small, nice addition: you can use underscores in numeric literals for improved readability.

This will shave off a few seconds every time you had to count how many digits a number had.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable=Underscores in Numeric Literals - Python 3.6+This one is a small, nice addition: you can use underscores in numeric literals for improved readability.This will shave off a few seconds every time you had to count how many digits a number had.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="9⃣" title="Tastenkappe Ziffer 9" aria-label="Emoji: Tastenkappe Ziffer 9">Underscores in Numeric Literals - Python 3.6+This one is a small, nice addition: you can use underscores in numeric literals for improved readability.This will shave off a few seconds every time you had to count how many digits a number had.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about underscores in numeric literals:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.python.org/dev/peps/pep-0515/

https://www.python.org/dev/peps/... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔟" title="Taste 10" aria-label="Emoji: Taste 10"> LRU Cache - Python 3.2+

Using the functools.lru_cache decorator, you can wrap any function with a memoizing callable that implements a Least Recently Used (LRU) algorithm to evict the least recently used entries.

Do you want fast code? Look into this.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
https://abs.twimg.com/emoji/v2/... draggable= LRU Cache - Python 3.2+Using the functools.lru_cache decorator, you can wrap any function with a memoizing callable that implements a Least Recently Used (LRU) algorithm to evict the least recently used entries.Do you want fast code? Look into this.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔟" title="Taste 10" aria-label="Emoji: Taste 10"> LRU Cache - Python 3.2+Using the functools.lru_cache decorator, you can wrap any function with a memoizing callable that implements a Least Recently Used (LRU) algorithm to evict the least recently used entries.Do you want fast code? Look into this.https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">" class="img-responsive" style="max-width:100%;"/>
More information about the lru_cache decorator:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> #functools.lru_cache">https://docs.python.org/3/library/functools.html #functools.lru_cache
https://docs.python.org/3/library... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="▫️" title="Weißes kleines Quadrat" aria-label="Emoji: Weißes kleines Quadrat"> https://www.cameronmacleod.com/blog/python-lru-cache

https://www.cameronmacleod.com/blog/pyth... class="Emoji" style="height:16px;" src=" https://abs.twimg.com/emoji/v2/... draggable="false" alt="👇" title="Rückhand Zeigefinger nach unten" aria-label="Emoji: Rückhand Zeigefinger nach unten">
Are there any specific Python 3 features that you& #39;d like to discuss?
You can follow @svpino.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: