What is this strange assignment statement?

I’m examining some code from a simple card game called AceyDucey. There are two lines that seem to be doing some kind of assignment, but I’ve never seen something like this in Python before. I was wondering if someone could tell me what kind of assignment (or other thing) this is:

Suit: TypeAlias = Literal["\u2665", "\u2666", "\u2663", "\u2660"]
Rank: TypeAlias = Literal[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

The full code of the game can be found here on GitHub.

These lines are saying that the programmer wants to create two new “types” which he will refer to as Suit and Rank.

Normally, Python variables do not need a declared type but here the programmer wants to be able to use these terms to make it clear how the code works.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.