Skip to content

Instantly share code, notes, and snippets.

@juftin
Last active August 31, 2023 19:28
Show Gist options
  • Save juftin/9ee4a35a1be07ede62281df05a805f3f to your computer and use it in GitHub Desktop.
Save juftin/9ee4a35a1be07ede62281df05a805f3f to your computer and use it in GitHub Desktop.
string literals
from typing import Literal, TypedDict
DENSE_CALCIUM_VOLUME: Literal["denseCalciumVolume"] = "denseCalciumVolume"
FATTY_FIBROUS_VOLUME: Literal["fattyFibrousVolume"] = "fattyFibrousVolume"
TOTAL_CALCIFIED_PLAQUE_VOLUME = "totalCalcifiedPlaqueVolume"
class TypedCleerlyDict(TypedDict):
denseCalciumVolume: float
fattyFibrousVolume: float
totalCalcifiedPlaqueVolume: float
example: TypedCleerlyDict = {
"denseCalciumVolume": 0.2,
"fattyFibrousVolume": 1.0,
"totalCalcifiedPlaqueVolume": 23.2,
}
dcv: float = example[DENSE_CALCIUM_VOLUME]
tcpv: float = example[TOTAL_CALCIFIED_PLAQUE_VOLUME]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment