For three constants, I would use the unpacking version of the enum 'pattern':
Blocked, Wall, Floor = range(3)
If it gets more complex than that though, I would have a look at other enum types in python.
Make use of bit flags. You can search google for more information, in the simplest terms you can store Boolean values in binary form, since True/False is one bit you can make a 4 bits or 1 byte to store 4 different Booleans.
So let say it like this:
python syntax:
a = 0x0 #[ this is python representation of bit flag or binary number <class 'int'> or in python27 <type 'int'> ]
binary representation:
0x0 = 000 [ zero is zero it does not matter how long the binary variable is]
0x1 = 001 [ 1 ]
0x2 = 010 [ 2 ]
0x4 = 100 [ 4 ]
so here we have 3 or more different Boolean places that we can check, since 000000000001 == 001 == 01 == 0x1
but in bit flags
0x3 = 011 [3 = 2+1]
0x5 = 101 [5 = 4+1]
0x6 = 110 [6 = 4+2]
0x7 = 111 [7 = 4+2+1]
IN THE MOST SIMPLEST TERMS
I will give you one comparison syntax & which means AND, that means that place of '1' in bit flag must be the same. So in practical terms 0x1&0x2==0x2 will be False because 001&010 does not have '1' in the same place
so if you want to check for two types in bit flag just add them together and check, with syntax above.
example: 0x3&(0x1+0x2)==(0x1+0x2)
I hope this helps. Happy googling.
Python 3.12+
PEP 695 introduces a new, more compact and explicit way to create generic classes and functions. In addition, the PEP introduces a new way to declare type aliases using the type statement, which creates an instance of TypeAliasType. As a result, you can do this:
type Point = tuple[float, float]
# or
type Point[T] = tuple[T, T] # more generic
For example, you can use it like this:
type Point = tuple[int, int]
p: Point = (0,0)
print(p) # (0,0)
p = (4,5) # re-assign Point p
print(p[0]) # 4, your "x"
print(p[1]) # 5, your "y"
Depending on your use case, this answer may not be relevant.
I am not sure what you want to do with the tuple. p will always be an instance of Point. What you intend to do there won't work.
If you just want to use the dot notation, you could use a namedtuple or a dataclass instead of a class. Then cast their instances to a tuple using tuple() and astuple().
Using a namedtuple and tuple():
from collections import namedtuple
Point = namedtuple("Point", ["x", "y"])
p = Point(4, 5)
x = p.x
y = p.y
xy = p # xy = tuple(p) not necessary since namedtuple is already a tuple
Note: namedtuple is immutable, i.e. you can't change x and y.
Using a dataclasses.dataclass and dataclasses.astuple():
from dataclasses import dataclass, astuple
@dataclass
class Point:
x: int
y: int
p = Point(4, 5)
x = p.x
y = p.y
xy = astuple(p)