Last active
March 15, 2017 18:02
-
-
Save konradhalas/c11fbea9edb63bdd9aa4ce1c8537e206 to your computer and use it in GitHub Desktop.
This is a short example of a new "typed" named tuple syntax (Python 3.6). It's a very clean and easy way to define data classes with a type hinting and inheritance support.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import NamedTuple # >= Python.3.6.0 | |
class Employee(NamedTuple): | |
name: str | |
department: str | |
salary: int | |
is_remote: bool = False # >= Python.3.6.1 | |
bob = Employee(name='Bob', department='IT', salary=10000, is_remote=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment