>
> The bytecode compiler doesn't know that you intend RANGE
> to be a constant -- it thinks it's a variable to bind a
> value to.
>
> To make this work you need to find a way to refer to the
> value that isn't just a bare name. One way would be to
> define your constants using an enum:
>
> class O
On Thu, 8 Jun 2023 at 08:19, Jason Friedman via Python-list
wrote:
>
> This gives the expected results:
>
> with open(data_file, newline="") as reader:
> csvreader = csv.DictReader(reader)
> for row in csvreader:
> #print(row)
> match row[RULE_TYPE]:
> case "RANGE":
> print("range")
> case "MANDAT
On 8/06/23 10:18 am, Jason Friedman wrote:
SyntaxError: name capture 'RANGE' makes remaining patterns unreachable
The bytecode compiler doesn't know that you intend RANGE
to be a constant -- it thinks it's a variable to bind a
value to.
To make this work you need to find a way to refer to the
This gives the expected results:
with open(data_file, newline="") as reader:
csvreader = csv.DictReader(reader)
for row in csvreader:
#print(row)
match row[RULE_TYPE]:
case "RANGE":
print("range")
case "MANDATORY":
print("mandatory")
case _:
print("nothing to do")
This:
RANGE = "RANGE"
MANDATORY