{"id":12339,"date":"2016-05-18T12:11:33","date_gmt":"2016-05-18T09:11:33","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=12339"},"modified":"2016-05-11T07:10:57","modified_gmt":"2016-05-11T04:10:57","slug":"object-literals-python","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/","title":{"rendered":"\u201cObject Literals\u201d in Python"},"content":{"rendered":"<p>This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013 am jealous of JavaScript. More specifically, I\u2019m jealous of JavaScript\u2019s object literals (also full-featured function literals, but I don\u2019t think I can do anything about that). Yes, in many respects, JS object literals are almost exactly the same thing as Python\u2019s dicts, but there is one important difference: dot notation access.<\/p>\n<p>So here\u2019s my attempt at accomplishing the closest thing possible toward making object literals in Python.<\/p>\n<h2><b>Attempt 1: Super Simple<\/b><\/h2>\n<p>The simplest way to make an \u201cobject literal\u201d class that I can think of is the following:<\/p>\n<pre class=\"brush:php\">class Object:\r\n   def __init__(self, **attributes):\r\n      self.__dict__.update(attributes)<\/pre>\n<p>That\u2019s it. You can make your literal like so:<\/p>\n<pre class=\"brush:php\">var = Object(\r\n   a = 1,\r\n   b = 2,\r\n   c = lambda x: x)<\/pre>\n<p>That\u2019s pretty nice and pretty easy. It\u2019s actually even nicer than JSON in some ways in that the names of the variables don\u2019t have to be string objects. Although, if you want it to be a bit closer to JSON syntax, you could pass in a spread out dictionary instead:<\/p>\n<pre class=\"brush:php\">var = Object(**{\r\n   \"a\": 1,\r\n   \"b\": 2,\r\n   \"c\": lambda x: x})<\/pre>\n<p>This way <i>does<\/i> require string objects and uses a colon instead of an <code>=<\/code>, just like JSON. Either syntax works with every attempt in this article.<\/p>\n<p>This <code>Object<\/code> class has a major shortcoming, though: it doesn\u2019t have methods. It can store functions just fine, but there\u2019s no way to provide those functions with the instance that they\u2019re stored on. We need to do some work.<\/p>\n<h2><b>Attempt 2: Adding Methods<\/b><\/h2>\n<p>In order to use methods properly, we need to know how methods work. First, they\u2019re non-data descriptors, so they have a <code>__get__()<\/code> method (if you want to learn a bunch more about Python descriptors, <a href=\"https:\/\/programmingideaswithjake.wordpress.com\/python-descriptors-book\/\">check out my book<\/a>). And that method is supplied implicitly with the instance it\u2019s called from as well as the class of the instance, which it uses to return a sort of partial function with <code>self<\/code> already set. The problem that our object literal setup has with this is the fact that everything is stored on the instance, and descriptors need to be stored on the class to work properly.<\/p>\n<p>Now, we can\u2019t just go through and dynamically add all the functions provided in the <code>attributes<\/code> argument onto the class. That could create potential conflicts between different object literals that add their own version of a function with that same name as another. No, we must override how attributes are accessed from the object.<\/p>\n<p>There are two ways to do this: <code>__getattribute__()<\/code> and <code>__getattr__()<\/code>. Generally it is recommended to avoid overriding <code>__getattribute__()<\/code>, since it\u2019s the one that contains all the existing lookup and descriptor logic. <code>__getattr__()<\/code> is called by <code>__getattribute__()<\/code> when it fails to find the attribute on its own, making <code>__getattr__()<\/code> sort of a backup system.<\/p>\n<p>We could really use either one, but overriding <code>__getattr__()<\/code> would require us to override <code>__setattr__()<\/code> and <code>__delattr__()<\/code>, too, since the only way to ensure that <code>__getattr__()<\/code> is called is to store the attributes <i>within<\/i> an attribute \u2013 preferably one that is made \u201cprivate\u201d with a name prefixed with \u201c<code>__<\/code>\u201c. We\u2019ll need to override <code>__setattr__()<\/code> and <code>__delattr__()<\/code> later anyway, but I would prefer to avoid the extra attribute.<\/p>\n<p>So, we\u2019re going to override <code>__getattribute__()<\/code>, despite the common wisdom of avoiding doing so. I feel that it\u2019s especially worthwhile to do so, since overriding <code>__getattribute__()<\/code> should imply that your class\/object isn\u2019t going to be \u201cnormal\u201d by Python\u2019s standards, and an object literal really isn\u2019t, since it\u2019s doesn\u2019t really <i>have<\/i> a class associated with it, in a sense. Plus, if you\u2019re going to override how descriptors are used, that\u2019s what overriding <code>__getattribute__()<\/code> is for.<\/p>\n<p>So, we\u2019ll change <code>__getattribute__()<\/code> to retrieve the value using the built-in <code>__getattribute__()<\/code> implementation, and then check if that value has a <code>__get__()<\/code> method. If it does, call it.<\/p>\n<p>Here\u2019s the complete code with the new change:<\/p>\n<pre class=\"brush:php\">class Object:\r\n   def __init__(self, **attributes):\r\n      self.__dict__.update(attributes)\r\n\r\n   def __getattribute__(self, item):\r\n      value = super().__getattribute__(item)\r\n      if hasattr(value, \"__get__\"):\r\n         return value.__get__(self, Object)\r\n      else:\r\n         return value<\/pre>\n<p>Those who know how descriptor usage normally works may be noticing that it doesn\u2019t follow the typical priority list that is normally there. Normally, it looks for data descriptors under the name, then checks the instance, then checks for non-data descriptors or other class attributes. This just checks for <code>__get__()<\/code>. This is because there\u2019s nothing on the class to check. It\u2019s all instance-based, so we just check if it\u2019s a descriptor with <code>__get__()<\/code> or not.<\/p>\n<h2><b>What About Normal Functions?<\/b><\/h2>\n<p>So, what if you want to put a function into an object literal that doesn\u2019t have a <code>self<\/code> parameter? Handily, Python actually already takes care of that: <code>staticmethod()<\/code>. Just pass the function into <code>staticmethod<\/code>, and it will return a descriptor that ignores the instance and class passed into <code>__get__()<\/code>. For example:<\/p>\n<pre class=\"brush:php\">def afunc(param):\r\n   print(param)\r\n\r\nliteral = Object(\r\n   sm = staticmethod(afunc))<\/pre>\n<h2><b>Attempt 3: All Descriptor Methods<\/b><\/h2>\n<p>So, we\u2019ve implemented the ability to use the <code>__get__()<\/code> methods of descriptors. It\u2019s time that we do the same for <code>__set__()<\/code> and <code>__delete__()<\/code>. Don\u2019t forget (assuming you already knew), that if a descriptor is a data descriptor that doesn\u2019t implement one of those methods, it raises an <code>AttributeError<\/code> when trying to use the non-existent method.<\/p>\n<pre class=\"brush:php\">class Object:\r\n   def __init__(self, **attributes):\r\n      self.__dict__.update(attributes)\r\n\r\ndef __getattribute__(self, item):\r\n   attr = super().__getattribute__(item)\r\n   if hasattr(attr, \"__get__\"):\r\n      return attr.__get__(self, Object)\r\n   else:\r\n      return attr\r\n\r\ndef __setattr__(self, key, value):\r\n   attr = super().__getattribute__(key)\r\n   if hasattr(attr, '__set__'):\r\n      attr.__set__(self, value)\r\n   elif hasattr(attr, '__delete__'):\r\n      raise AttributeError(key + ' has no attribute, \"__set__\"')\r\n   else:\r\n      self.__dict__[key] = value\r\n\r\ndef __delattr__(self, item):\r\n   attr = super().__getattribute__(item)\r\n   if hasattr(attr, '__delete__'):\r\n      attr.__delete__(self, item)\r\n   elif hasattr(attr, '__set__'):\r\n      raise AttributeError(item + ' has no attribute, \"__delete__\"')\r\n   else:\r\n      del self.__dict__[item]<\/pre>\n<p>There, that\u2019s all there is to it. You know, an interesting thing happens when you use the object literal class; you can design descriptors for it much more easily than for typical classes and instances. A large portion of my book about descriptors is about how to store attributes safely, and with on-instance descriptors for object literals, you just need to store one little attribute on there. I just thought that was interesting.<\/p>\n<h2><b>Outro<\/b><\/h2>\n<p>So that\u2019s how you add object literals to Python. I\u2019m not saying it\u2019s a good idea; I\u2019m just showing you my thought experiment, and how it could be done if you really wanted it.<\/p>\n<p>My next few posts are going to be a (probably short)video series on moving a Java codebase to Kotlin. I don\u2019t know how long it will take to make any of them, so it may be a little while before a post shows up on here. I hope you\u2019re all looking forward to it as much as I am.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/programmingideaswithjake.wordpress.com\/2016\/05\/07\/object-literals-in-python\/\">\u201cObject Literals\u201d in Python<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Jacob Zimmerman at the <a href=\"http:\/\/programmingideaswithjake.wordpress.com\/\">Programming Ideas With Jake<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013 am jealous of JavaScript. More specifically, I\u2019m jealous of JavaScript\u2019s object literals (also full-featured function literals, but I don\u2019t think I can do anything &hellip;<\/p>\n","protected":false},"author":51,"featured_media":1651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"class_list":["post-12339","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u201cObject Literals\u201d in Python - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u201cObject Literals\u201d in Python - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-18T09:11:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jacob Zimmerman\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/jacobz_20\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jacob Zimmerman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\"},\"author\":{\"name\":\"Jacob Zimmerman\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f54a53cfb8523f4ef6012aa63f075c39\"},\"headline\":\"\u201cObject Literals\u201d in Python\",\"datePublished\":\"2016-05-18T09:11:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\"},\"wordCount\":1022,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\",\"name\":\"\u201cObject Literals\u201d in Python - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"datePublished\":\"2016-05-18T09:11:33+00:00\",\"description\":\"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u201cObject Literals\u201d in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f54a53cfb8523f4ef6012aa63f075c39\",\"name\":\"Jacob Zimmerman\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2dfdd9e2d35ed2224faf73968f8c597b5489fc345287e06e2571d3935a6bcc86?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2dfdd9e2d35ed2224faf73968f8c597b5489fc345287e06e2571d3935a6bcc86?s=96&d=mm&r=g\",\"caption\":\"Jacob Zimmerman\"},\"description\":\"Jacob is a certified Java programmer (level 1) and Python enthusiast. He loves to solve large problems with programming and considers himself pretty good at design.\",\"sameAs\":[\"https:\/\/programmingideaswithjake.wordpress.com\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/jacobz_20\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/jacob-zimmerman\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u201cObject Literals\u201d in Python - Web Code Geeks - 2026","description":"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/","og_locale":"en_US","og_type":"article","og_title":"\u201cObject Literals\u201d in Python - Web Code Geeks - 2026","og_description":"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013","og_url":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-05-18T09:11:33+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","type":"image\/jpeg"}],"author":"Jacob Zimmerman","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/jacobz_20","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Jacob Zimmerman","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/"},"author":{"name":"Jacob Zimmerman","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f54a53cfb8523f4ef6012aa63f075c39"},"headline":"\u201cObject Literals\u201d in Python","datePublished":"2016-05-18T09:11:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/"},"wordCount":1022,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/","url":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/","name":"\u201cObject Literals\u201d in Python - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","datePublished":"2016-05-18T09:11:33+00:00","description":"This may come as a shock to my regular readers, but even as a Pythonista and Kotlinite, I\u2019m a little jealous of JavaScript. That\u2019s right; I \u2013 a JS hater \u2013","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/python\/object-literals-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/www.webcodegeeks.com\/category\/python\/"},{"@type":"ListItem","position":3,"name":"\u201cObject Literals\u201d in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f54a53cfb8523f4ef6012aa63f075c39","name":"Jacob Zimmerman","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2dfdd9e2d35ed2224faf73968f8c597b5489fc345287e06e2571d3935a6bcc86?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2dfdd9e2d35ed2224faf73968f8c597b5489fc345287e06e2571d3935a6bcc86?s=96&d=mm&r=g","caption":"Jacob Zimmerman"},"description":"Jacob is a certified Java programmer (level 1) and Python enthusiast. He loves to solve large problems with programming and considers himself pretty good at design.","sameAs":["https:\/\/programmingideaswithjake.wordpress.com\/","https:\/\/x.com\/https:\/\/twitter.com\/jacobz_20"],"url":"https:\/\/www.webcodegeeks.com\/author\/jacob-zimmerman\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/12339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=12339"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/12339\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/1651"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=12339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=12339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=12339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}