{"id":996,"date":"2023-02-17T17:54:00","date_gmt":"2023-02-17T12:24:00","guid":{"rendered":"https:\/\/geekpython.in\/?p=996"},"modified":"2023-08-15T14:25:22","modified_gmt":"2023-08-15T08:55:22","slug":"match-case-in-python","status":"publish","type":"post","link":"https:\/\/geekpython.in\/match-case-in-python","title":{"rendered":"How To Use Match Case Statement For Pattern Matching In Python"},"content":{"rendered":"\n<p>Python programming language is constantly evolving and every new version of it brings something interesting and new. In Python version&nbsp;<strong>3.10<\/strong>, the &#8220;<strong>match case<\/strong>&#8221; statement was proposed in the&nbsp;<a target=\"_blank\" href=\"https:\/\/peps.python.org\/pep-0634\/\" rel=\"noreferrer noopener\">PEP 634<\/a>(specification) &amp;&nbsp;<a target=\"_blank\" href=\"https:\/\/peps.python.org\/pep-0636\/\" rel=\"noreferrer noopener\">636<\/a>(tutorial) for structural pattern matching.<\/p>\n\n\n\n<p>Just like other programming languages like C, Java, JavaScript, and more has a&nbsp;<code>switch<\/code>&nbsp;statement that provides a way to perform conditional operations based on the values of an expression. The&nbsp;<code>switch<\/code>&nbsp;statement allows us to execute the block of code based on the value of the single expression.<\/p>\n\n\n\n<p>But Python didn&#8217;t have that amenity from the start instead of an&nbsp;<code>if-else<\/code>&nbsp;statement, so in the recent version of Python, the&nbsp;<code>match case<\/code>&nbsp;statement was introduced that functions similarly to the&nbsp;<code>switch<\/code>&nbsp;statement.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-if-else-statement\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-if-else-statement\"><\/a>If-Else Statement<\/h1>\n\n\n\n<p>Before the proposal or release of the match case statement in Python, the&nbsp;<code>if-else<\/code>&nbsp;statement is primarily used for pattern matching or performing conditional operations.<\/p>\n\n\n\n<p>Here&#8217;s an example of using the&nbsp;<code>if-else<\/code>&nbsp;statement to perform the conditional operation.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">user = input(\"Enter the number: \")\n\nif int(user) &gt; 10:\n    print(\"Greater than 10\")\n\nelif int(user) &lt; 10:\n    print(\"Less than 10\")\n\nelse:\n    print(\"It's sleeping time.\")<\/pre><\/div>\n\n\n\n<p>In the above code, we specified some conditions and which condition will be going to be true depends on the value of the single expression which the user in the console will enter.<\/p>\n\n\n\n<p>Here, if the user inputs a value greater than 10 then the first condition will be going to be true and the program terminates but if the value is less than 10, the program will check the first condition if that&#8217;s not true then it will move onto the following condition if it found the match then it will execute the condition and terminates there.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:ps decode:true \">Enter the number: 10\nIt's sleeping time.\n-----------------------\nEnter the number: 9\nLess than 10\n-----------------------\nEnter the number: 11\nGreater than 10<\/pre><\/div>\n\n\n\n<p>The program will always look for a match and in the end, will execute the condition that matches the user&#8217;s requirement.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-match-case-statement\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-match-case-statement\"><\/a>Match Case Statement<\/h1>\n\n\n\n<p>The newly added&nbsp;<code>match case<\/code>&nbsp;statement functions similarly to the&nbsp;<code>if-else<\/code>&nbsp;statement and if you have worked with other programming languages like&nbsp;<strong>C<\/strong>,&nbsp;<strong>JavaScript<\/strong>&nbsp;and more, then it&#8217;ll give you the feel like the&nbsp;<code>switch<\/code>&nbsp;statement.<\/p>\n\n\n\n<p>The&nbsp;<code>match<\/code>&nbsp;statement takes an expression and compares its value with the&nbsp;<strong>case blocks<\/strong>&nbsp;which have some specified conditions. Take a look at the following example showing the simplest demonstration of the&nbsp;<code>match<\/code>&nbsp;statement.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">greet = \"Hey\"\n\nmatch greet:\n    case \"Hey\":\n        print(\"Welcome to GeekPython.\")\n    case \"Hello\":\n        print(\"Welcome Geeks.\")\n    case _:\n        print(\"Matches anything.\")<\/pre><\/div>\n\n\n\n<p>In the above code, we created a variable&nbsp;<code>greet<\/code>&nbsp;in which a value&nbsp;<code>\"Hey\"<\/code>&nbsp;is stored and then we created the&nbsp;<code>match case<\/code>&nbsp;block. First, we wrote the&nbsp;<code>match<\/code>&nbsp;keyword and specified the parameter then we defined the&nbsp;<code>case<\/code>&nbsp;blocks where we wrote the conditions and whichever condition will be true gets executed.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Welcome to GeekPython.<\/pre><\/div>\n\n\n\n<p>In the last case block, we defined&nbsp;<code>case _<\/code>, where the variable name&nbsp;<code>_<\/code>&nbsp;acts as a wildcard and it will never fail to match. If no case matches in the upper code then the last case block is executed.<\/p>\n\n\n\n<p>In the sections ahead, you&#8217;ll discover many other concepts in the&nbsp;<code>match<\/code>&nbsp;statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-guard\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-guard\"><\/a>Guard<\/h2>\n\n\n\n<p>The&nbsp;<code>guard<\/code>&nbsp;in the&nbsp;<code>match<\/code>&nbsp;statement is nothing but using&nbsp;<code>if<\/code>&nbsp;statement in the&nbsp;<strong>case block<\/strong>. It is a part of the case block and the syntax is:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">case case_here if named_expression<\/pre><\/div>\n\n\n\n<p>The idea behind the&nbsp;<code>guard<\/code>&nbsp;or using the&nbsp;<code>if<\/code>&nbsp;statement in the case block is when the condition is matched with the case, the program will not execute it right away it then moves on to the&nbsp;<strong>guard condition<\/strong>&nbsp;or&nbsp;<code>if<\/code>&nbsp;<strong>condition<\/strong>&nbsp;and if the&nbsp;<code>if<\/code>&nbsp;<strong>condition<\/strong>&nbsp;is true, then the block is executed else it will not be executed.<\/p>\n\n\n\n<p>Another logical flow of the&nbsp;<code>case<\/code>&nbsp;with the&nbsp;<code>guard<\/code>&nbsp;is if the case doesn&#8217;t match then the guard will not be evaluated and the program moves to the next case block.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">num = 10\nmatch (\"Hey\", 1):\n    case (\"Hello\", 10):\n        print(\"Case 1 matched\")\n    case (\"Hey\", 1) if num == 1: # Case matched but guard fails\n        print(\"Case 2 matched\")\n    case (\"Hey\", n):\n        print(f\"Case 3 matched, n={n}\")\n    case _:\n        print(\"Match anything\")<\/pre><\/div>\n\n\n\n<p>If we look at the second&nbsp;<code>case<\/code>&nbsp;block that matches the condition that we defined in the&nbsp;<code>match<\/code>&nbsp;condition and after that program evaluates the&nbsp;<code>guard<\/code>&nbsp;but here, the&nbsp;<strong>guard condition<\/strong>&nbsp;is false, hence the program moves on to the next&nbsp;<code>case<\/code>&nbsp;block.<\/p>\n\n\n\n<p>In the third&nbsp;<code>case<\/code>&nbsp;block, it matches the condition and binds the&nbsp;<code>n<\/code>&nbsp;with the value&nbsp;<code>1<\/code>&nbsp;and the program executes the third&nbsp;<code>case<\/code>&nbsp;block.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Case 3 matched, n=1<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-using-or-pattern\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-using-or-pattern\"><\/a>Using OR Pattern<\/h2>\n\n\n\n<p>Pattern matching will not always be about matching a single condition, sometimes we might want to match either this or that condition and in that case, we can use the&nbsp;<code>|<\/code>&nbsp;(pipe) character in the&nbsp;<code>case<\/code>&nbsp;block to specify alternative patterns.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">match (\"Hey\", 1):\n    case (\"Hello\", 10):\n        print(\"Case 1 matched\")\n    case (\"Hey\", 10) | (\"Heya\", 1) | (\"Hey\", 1):\n        print(\"Case 2 matched\")\n    case _:\n        print(\"Match anything\")<\/pre><\/div>\n\n\n\n<p>Here&#8217;s a simple demonstration of using the&nbsp;<code>or<\/code>&nbsp;pattern where in the second&nbsp;<code>case<\/code>&nbsp;block,&nbsp;<strong>three conditions<\/strong>&nbsp;were defined, and if either one of them matches the condition the program is looking for, the&nbsp;<code>case<\/code>&nbsp;block will get executed.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Case 2 matched<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-matching-a-sequence\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-matching-a-sequence\"><\/a>Matching a Sequence<\/h2>\n\n\n\n<p>Sometimes we might want to create or define the specific program or function in which we wanted to match certain sequences from the dynamic or static data.<\/p>\n\n\n\n<p>Then at that time, we can use sequence matching and there are several methods to perform it but we&#8217;ll see how to do it in a&nbsp;<code>match case<\/code>&nbsp;statement.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">letter = \"Hello\"\n\nmatch (letter[4]):\n    case \"o\":\n        print(\"Case 1 matched\")\n    case \"a\":\n        print(\"Case 2 matched\")\n    case _:\n        print(\"Yohoho\")<\/pre><\/div>\n\n\n\n<p>In the above code, we are trying to match the condition of whether a specific character is present in our given sequence or not. This code will look for a case where the specific character matches the condition and then the program will execute it.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Case 1 matched<\/pre><\/div>\n\n\n\n<p>One more thing is that if we wanted to match one certain character from the sequence and then the whole sequence collectively then, in that case, we could use&nbsp;<code>*<\/code>&nbsp;with the variable name. This will simply grab all the values present in the data or sequence.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">def inputdata(data):\n    match data:\n        case [\"Hello\", *other]:\n            print(f\"First letter is 'Hello' and \"\n                  f\"Others are {other}\")\n        case [*word, \"Welcome\"]:\n            print(f\"Last word is 'Welcome' and the words \"\n                  f\"before is {word}\")\n        case _:\n            print(\"Yohoho\")\n\ninputdata([\"Hello\", \"Geeks\"])\ninputdata([\"Hey\", \"Geeks\", \"Welcome\"])<\/pre><\/div>\n\n\n\n<p>In the above code, the first case will match the word&nbsp;<strong>&#8220;Hello&#8221;<\/strong>&nbsp;from the given sequence and then match all the other items and the same goes for the second case block.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">First letter is 'Hello' and Others are ['Geeks']\nLast word is 'Welcome' and the words before is ['Hey', 'Geeks']<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-python-class-in-match-statement\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-python-class-in-match-statement\"><\/a>Python Class in Match Statement<\/h2>\n\n\n\n<p>We can also use Python classes for pattern matching using&nbsp;<code>match case<\/code>&nbsp;statements. This will help us manage our code easily, and the code will be easily readable in the case of a complex code structure.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">from dataclasses import dataclass\n\n@dataclass\nclass Hero:\n    real_name: str\n    reel_name: str\n    hero_name: str\n\ndef class_in_match(data):\n    match data:\n        case Hero(real_name, reel_name, hero_name):\n            print(f\"{real_name} plays the character of {reel_name} and \"\n                  f\"hero name is {hero_name}.\")\n\n        case Hero(\"Tobey Maguire\", \"Peter Parker\", \"SpiderMan\"):\n            print(\"Tobey Maguire plays the character of Peter Parker and \"\n                  \"hero name is SpiderMan.\")\n\nobj1 = Hero(\"RDJ\", \"Tony Stark\", \"IronMan\")\nobj2 = Hero(\"Tobey Maguire\", \"Peter Parker\", \"SpiderMan\")\n\nclass_in_match(obj1)\nclass_in_match(obj2)<\/pre><\/div>\n\n\n\n<p>In the above code, we used the&nbsp;<a target=\"_blank\" href=\"https:\/\/docs.python.org\/3\/library\/dataclasses.html\" rel=\"noreferrer noopener\">dataclass<\/a>&nbsp;and created our class&nbsp;<code>Hero<\/code>&nbsp;which has three arguments.<\/p>\n\n\n\n<p>In the next code block, we created a function&nbsp;<code>class_in_match<\/code>&nbsp;that takes the&nbsp;<code>data<\/code>&nbsp;as an argument, then we started the&nbsp;<code>match-case<\/code>&nbsp;ladder where the condition is to match the&nbsp;<code>data<\/code>&nbsp;and in the first&nbsp;<code>case<\/code>&nbsp;block, we instantiated the class&nbsp;<code>Hero<\/code>&nbsp;and passed the required arguments. In the second&nbsp;<code>case<\/code>&nbsp;block, instead of passing arguments, we passed the values of the arguments.<\/p>\n\n\n\n<p>Then we created the instance&nbsp;<code>obj1<\/code>&nbsp;and&nbsp;<code>obj2<\/code>&nbsp;for the class&nbsp;<code>Hero<\/code>&nbsp;and passed the values and then finally called the function&nbsp;<code>class_in_match<\/code>&nbsp;and passed the instance of the class.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">RDJ plays the character of Tony Stark and hero name is IronMan.\nTobey Maguire plays the character of Peter Parker and hero name is SpiderMan.<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-for-loop-with-match-case\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-for-loop-with-match-case\"><\/a>For Loop with Match Case<\/h2>\n\n\n\n<p>Like we used to do in the traditional way where we run&nbsp;<code>for loop<\/code>&nbsp;and then specify conditions using the&nbsp;<code>if-elif-else<\/code>&nbsp;ladder to carry out the specific task. This time we&#8217;ll see how to do it with the&nbsp;<code>match-case<\/code>&nbsp;statement.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">seq = \"GeekPython\"\n\nfor i in seq:\n    match i:\n        case \"y\":\n            print(f\"The sequence has letter {i}\")\n        case \"e\":\n            print(f\"The sequence has letter {i}\")\n        case _:\n            print(f\"Other letter {i}\")<\/pre><\/div>\n\n\n\n<p>The above code will run a&nbsp;<code>for loop<\/code>&nbsp;for every letter in the&nbsp;<code>seq<\/code>&nbsp;variable and tries to match&nbsp;<code>i<\/code>&nbsp;which is basically every letter in the&nbsp;<code>seq<\/code>, we created three&nbsp;<code>case<\/code>&nbsp;blocks, the first one matches if&nbsp;<code>seq<\/code>&nbsp;has the letter&nbsp;<code>\"y\"<\/code>&nbsp;in it, so does the second one but for the letter&nbsp;<code>\"e\"<\/code>&nbsp;and the third one matches the other letters.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Other letter G\nThe sequence has letter e\nThe sequence has letter e\nOther letter k\nOther letter P\nThe sequence has letter y\nOther letter t\nOther letter h\nOther letter o\nOther letter n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-match-case-with-python-dictionary\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-match-case-with-python-dictionary\"><\/a>Match Case with Python Dictionary<\/h2>\n\n\n\n<p>Here we&#8217;ll see how we can create the match-case statement using the Python dictionary. This can be very helpful when your project is on the cloud and the communication of the data needs to be in the&nbsp;<code>json<\/code>&nbsp;format or dictionary.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">data = {\n    \"name\": \"GeekPython\",\n    \"role\": \"Developer\",\n    \"type\": \"Python\"\n}\n\nmatch data[\"name\"][4:]:\n    case \"GeekPython\":\n        print(\"Case 1 matched\")\n    case \"Python\":\n        print(\"Case 2 matched\")\n    case \"python\":\n        print(\"Case 3 matched\")\n    case _:\n        print(\"Whatever\")<\/pre><\/div>\n\n\n\n<p>In the above code, the variable&nbsp;<code>data<\/code>&nbsp;is a dictionary and contains some&nbsp;<code>key-value<\/code>&nbsp;pairs and then we created the condition to match the&nbsp;<strong>value<\/strong>&nbsp;of the&nbsp;<strong>key<\/strong>&nbsp;<code>name<\/code>&nbsp;from the dictionary&nbsp;<code>data<\/code>. We created some&nbsp;<code>case<\/code>&nbsp;blocks and whichever&nbsp;<code>case<\/code>&nbsp;fulfils the required condition will get executed.<\/p>\n\n\n\n<p>The condition is to match the&nbsp;<strong>value<\/strong>&nbsp;of the&nbsp;<strong>key<\/strong>&nbsp;<code>name<\/code>&nbsp;starting from the index number 4 and the second case perfectly matches the specified condition.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Case 2 matched<\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-conclusion\"><a href=\"https:\/\/geekpython.in\/match-case-in-python#heading-conclusion\"><\/a>Conclusion<\/h1>\n\n\n\n<p>The&nbsp;<code>match-case<\/code>&nbsp;statement was added in Python&nbsp;<code>v3.10<\/code>&nbsp;and in the first look, it gives the feeling of using switch statements like in other programming languages. Sure, Python has an&nbsp;<code>if-else<\/code>&nbsp;statement but adding a&nbsp;<code>match-case<\/code>&nbsp;statement in Python comes with a great plus point.<\/p>\n\n\n\n<p>In this article, we&#8217;ve seen the usage of the&nbsp;<code>match-case<\/code>&nbsp;statement and along with it understood some important concepts of the&nbsp;<code>match-case<\/code>&nbsp;statement with code examples.<\/p>\n\n\n\n<p>The&nbsp;<code>match-case<\/code>&nbsp;statement functions similarly to the&nbsp;<code>if-else<\/code>&nbsp;statement and the syntax is also similar to some extent.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83c\udfc6<strong>Other articles you might like if you like this article<\/strong><\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/access-modifiers-in-python\" rel=\"noreferrer noopener\">Using underscores to control the behaviour of the methods in the Python class<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/class-inheritance-in-python\" rel=\"noreferrer noopener\">Class Inheritance in Python and types of inheritance<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/build-api-using-fastapi\" rel=\"noreferrer noopener\">Build Web APIs in just a few steps using FastAPI<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/render-images-from-flask\" rel=\"noreferrer noopener\">Upload and display images on the frontend using Flask<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/data-augmentation-in-deep-learning\" rel=\"noreferrer noopener\">An intuitive guide to data augmentation in deep learning using Python<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/flask-app-for-image-recognition\" rel=\"noreferrer noopener\">Implement a deep learning model in the Flask app for image recognition<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>That&#8217;s all for now<\/strong><\/p>\n\n\n\n<p><strong>Keep Coding\u270c\u270c<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python programming language is constantly evolving and every new version of it brings something interesting and new. In Python version&nbsp;3.10, the &#8220;match case&#8221; statement was proposed in the&nbsp;PEP 634(specification) &amp;&nbsp;636(tutorial) for structural pattern matching. Just like other programming languages like C, Java, JavaScript, and more has a&nbsp;switch&nbsp;statement that provides a way to perform conditional operations [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":998,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[2],"tags":[12,31],"class_list":["post-996","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-python3","entry","has-media"],"_links":{"self":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":3,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":1314,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/996\/revisions\/1314"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/media\/998"}],"wp:attachment":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}