Skip to content

Instantly share code, notes, and snippets.

@konradhalas
Last active March 15, 2017 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konradhalas/c11fbea9edb63bdd9aa4ce1c8537e206 to your computer and use it in GitHub Desktop.
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.
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