From dd4430a68e6e72898aeebbba2fb072047296a735 Mon Sep 17 00:00:00 2001 From: Maanik Garg Date: Sat, 4 Apr 2026 13:25:38 +0530 Subject: [PATCH] fix: use raw strings for regex patterns in Lesson 6.1 grading The REGEX_CATEGORIES dict in Exercise 6.1 uses backslash-escaped parentheses (e.g., "A\) P") which triggers Python SyntaxWarning for invalid escape sequences. Adding the r prefix makes them proper raw strings so the regex engine receives the intended patterns. Fixed across all three tutorial variants: Anthropic 1P, AmazonBedrock anthropic, and AmazonBedrock boto3. Fixes #103 --- .../anthropic/06_Precognition_Thinking_Step_by_Step.ipynb | 8 ++++---- .../boto3/06_Precognition_Thinking_Step_by_Step.ipynb | 8 ++++---- .../06_Precognition_Thinking_Step_by_Step.ipynb | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/prompt_engineering_interactive_tutorial/AmazonBedrock/anthropic/06_Precognition_Thinking_Step_by_Step.ipynb b/prompt_engineering_interactive_tutorial/AmazonBedrock/anthropic/06_Precognition_Thinking_Step_by_Step.ipynb index c8bd5a8d..e8546c17 100755 --- a/prompt_engineering_interactive_tutorial/AmazonBedrock/anthropic/06_Precognition_Thinking_Step_by_Step.ipynb +++ b/prompt_engineering_interactive_tutorial/AmazonBedrock/anthropic/06_Precognition_Thinking_Step_by_Step.ipynb @@ -247,10 +247,10 @@ "\n", "# Dictionary of string values for each category to be used for regex grading\n", "REGEX_CATEGORIES = {\n", - " \"A\": \"A\\) P\",\n", - " \"B\": \"B\\) B\",\n", - " \"C\": \"C\\) B\",\n", - " \"D\": \"D\\) O\"\n", + " \"A\": r\"A\\) P\",\n", + " \"B\": r\"B\\) B\",\n", + " \"C\": r\"C\\) B\",\n", + " \"D\": r\"D\\) O\"\n", "}\n", "\n", "# Iterate through list of emails\n", diff --git a/prompt_engineering_interactive_tutorial/AmazonBedrock/boto3/06_Precognition_Thinking_Step_by_Step.ipynb b/prompt_engineering_interactive_tutorial/AmazonBedrock/boto3/06_Precognition_Thinking_Step_by_Step.ipynb index ed193597..cb394906 100755 --- a/prompt_engineering_interactive_tutorial/AmazonBedrock/boto3/06_Precognition_Thinking_Step_by_Step.ipynb +++ b/prompt_engineering_interactive_tutorial/AmazonBedrock/boto3/06_Precognition_Thinking_Step_by_Step.ipynb @@ -253,10 +253,10 @@ "\n", "# Dictionary of string values for each category to be used for regex grading\n", "REGEX_CATEGORIES = {\n", - " \"A\": \"A\\) P\",\n", - " \"B\": \"B\\) B\",\n", - " \"C\": \"C\\) B\",\n", - " \"D\": \"D\\) O\"\n", + " \"A\": r\"A\\) P\",\n", + " \"B\": r\"B\\) B\",\n", + " \"C\": r\"C\\) B\",\n", + " \"D\": r\"D\\) O\"\n", "}\n", "\n", "# Iterate through list of emails\n", diff --git a/prompt_engineering_interactive_tutorial/Anthropic 1P/06_Precognition_Thinking_Step_by_Step.ipynb b/prompt_engineering_interactive_tutorial/Anthropic 1P/06_Precognition_Thinking_Step_by_Step.ipynb index f5538aab..ac443e6e 100644 --- a/prompt_engineering_interactive_tutorial/Anthropic 1P/06_Precognition_Thinking_Step_by_Step.ipynb +++ b/prompt_engineering_interactive_tutorial/Anthropic 1P/06_Precognition_Thinking_Step_by_Step.ipynb @@ -241,10 +241,10 @@ "\n", "# Dictionary of string values for each category to be used for regex grading\n", "REGEX_CATEGORIES = {\n", - " \"A\": \"A\\) P\",\n", - " \"B\": \"B\\) B\",\n", - " \"C\": \"C\\) B\",\n", - " \"D\": \"D\\) O\"\n", + " \"A\": r\"A\\) P\",\n", + " \"B\": r\"B\\) B\",\n", + " \"C\": r\"C\\) B\",\n", + " \"D\": r\"D\\) O\"\n", "}\n", "\n", "# Iterate through list of emails\n",