{"id":19616,"date":"2022-11-07T06:30:47","date_gmt":"2022-11-07T01:00:47","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/"},"modified":"2022-11-07T06:30:47","modified_gmt":"2022-11-07T01:00:47","slug":"solved-save-a-list-of-objects-on-exit-of-pygame-game-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/","title":{"rendered":"[Solved] Save a list of objects on exit of pygame game [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-19004513\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"19004513\" data-parentid=\"19003633\" data-score=\"5\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<blockquote>\n<p>Perfect! Right?<\/p>\n<\/blockquote>\n<p>Sadly, no. What you see here (<code>&lt;__main__.Block object at 0x02416B70&gt;<\/code>) is a typical string representation of a class instance. It&#8217;s just a simple string, and there&#8217;s no way to convert this string back to an instance of of <code>Block<\/code>.<\/p>\n<p>I assume you&#8217;re still on this game from your last question.<\/p>\n<p>So how do you actually persist the state of the game? The easiest way is to use the standard python module <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.python.org\/2\/library\/pickle.html\"><code>pickle<\/code><\/a> or <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.python.org\/2\/library\/shelve.html\"><code>shelve<\/code><\/a>. <\/p>\n<p>In the following example, I&#8217;ll use <code>shelve<\/code>, because you don&#8217;t use a single class to represent the game state:<\/p>\n<blockquote>\n<p>A \u201cshelf\u201d is a persistent, dictionary-like object. &#8230; the values &#8230; in a shelf can be essentially arbitrary Python objects &#8230; This includes most class instances, recursive data types, and objects containing lots of shared sub-objects. The keys are ordinary strings.<\/p>\n<\/blockquote>\n<p>First of all, when we exit the game, we want to save the player and the blocks, so let&#8217;s call a new <code>save<\/code> function when the game is about to exit:<\/p>\n<pre><code>while True:\n    ...\n    for event in pygame.event.get():\n        if event.type == QUIT: \n            save(player, blocklist)\n            exit()\n<\/code><\/pre>\n<p>The implementation is quite easy (no error handling for brevity):<\/p>\n<pre><code>def save(player, blocks):\n    f = shelve.open(\"save.bin\") \n    f['player'] = player\n    f['blocks'] = blocks\n    f.close()\n<\/code><\/pre>\n<p>As you see, using <code>shelve<\/code> is as easy as using a <code>dict<\/code>.<\/p>\n<p>Next step is loading our saved data. <\/p>\n<pre><code>player, blocklist = load() or (None, [])\n<\/code><\/pre>\n<p>We call a new function <code>load<\/code> which will either return a tuple of the saved player object and a list of the saved block objects, or <code>None<\/code>. In case of <code>None<\/code>, we don&#8217;t create a player yet and use an empty list for our blocks.<\/p>\n<p>The implementation is as simple as the <code>save<\/code> functon:<\/p>\n<pre><code>def load():\n    try:\n        f = shelve.open(\"save.bin\") \n        return f['player'], f['blocks']\n    except KeyError:\n        return None\n    finally:\n        f.close()\n<\/code><\/pre>\n<p>And that&#8217;s it.<\/p>\n<p>Here&#8217;s the complete code:<\/p>\n<pre><code>import pygame,random\nfrom pygame.locals import *\nfrom collections import namedtuple\nimport shelve\n\npygame.init()\nclock=pygame.time.Clock()\nscreen=pygame.display.set_mode((640,480))\n\nmax_gravity = 100\n\nclass Block(object):\n    sprite = pygame.image.load(\"dirt.png\").convert_alpha()\n    def __init__(self, x, y):\n        self.rect = self.sprite.get_rect(centery=y, centerx=x)\n\nclass Player(object):\n    sprite = pygame.image.load(\"dirt.png\").convert()\n    sprite.fill((0,255,0))\n    def __init__(self, x, y):\n        self.rect = self.sprite.get_rect(centery=y, centerx=x)\n        # indicates that we are standing on the ground\n        # and thus are \"allowed\" to jump\n        self.on_ground = True\n        self.xvel = 0\n        self.yvel = 0\n        self.jump_speed = 10\n        self.move_speed = 8\n\n    def update(self, move, blocks):\n\n        # check if we can jump \n        if move.up and self.on_ground: \n            self.yvel -= self.jump_speed\n\n        # simple left\/right movement\n        if move.left: self.xvel = -self.move_speed\n        if move.right: self.xvel = self.move_speed\n\n        # if in the air, fall down\n        if not self.on_ground:\n            self.yvel += 0.3\n            # but not too fast\n            if self.yvel &gt; max_gravity: self.yvel = max_gravity\n\n        # if no left\/right movement, x speed is 0, of course\n        if not (move.left or move.right):\n            self.xvel = 0\n\n        # move horizontal, and check for horizontal collisions\n        self.rect.left += self.xvel\n        self.collide(self.xvel, 0, blocks)\n\n        # move vertically, and check for vertical collisions\n        self.rect.top += self.yvel\n        self.on_ground = False;\n        self.collide(0, self.yvel, blocks)\n\n    def collide(self, xvel, yvel, blocks):\n        # all blocks that we collide with\n        for block in [blocks[i] for i in self.rect.collidelistall(blocks)]:\n\n            # if xvel is &gt; 0, we know our right side bumped \n            # into the left side of a block etc.\n            if xvel &gt; 0: self.rect.right = block.rect.left\n            if xvel &lt; 0: self.rect.left = block.rect.right\n\n            # if yvel &gt; 0, we are falling, so if a collision happpens \n            # we know we hit the ground (remember, we seperated checking for\n            # horizontal and vertical collision, so if yvel != 0, xvel is 0)\n            if yvel &gt; 0:\n                self.rect.bottom = block.rect.top\n                self.on_ground = True\n                self.yvel = 0\n            # if yvel &lt; 0 and a collision occurs, we bumped our head\n            # on a block above us\n            if yvel &lt; 0: self.rect.top = block.rect.bottom\n\ncolliding = False\nMove = namedtuple('Move', ['up', 'left', 'right'])\n\ndef load():\n    try:\n        f = shelve.open(\"save.bin\") \n        return f['player'], f['blocks']\n    except KeyError:\n        return None\n    finally:\n        f.close()\n\ndef save(player, blocks):\n    f = shelve.open(\"save.bin\") \n    f['player'] = player\n    f['blocks'] = blocks\n    f.close()\n\nplayer, blocklist = load() or (None, [])\n\nwhile True:\n    screen.fill((25,30,90))\n    mse = pygame.mouse.get_pos()\n    key = pygame.key.get_pressed()\n\n    for event in pygame.event.get():\n        if event.type == QUIT: \n            save(player, blocklist)\n            exit()\n\n        if key[K_LSHIFT]:\n            if event.type==MOUSEMOTION:\n                if not any(block.rect.collidepoint(mse) for block in blocklist):\n                    x=(int(mse[0]) \/ 32)*32\n                    y=(int(mse[1]) \/ 32)*32\n                    blocklist.append(Block(x+16,y+16))\n        else:\n            if event.type == pygame.MOUSEBUTTONUP:\n                if event.button == 1:\n                    to_remove = [b for b in blocklist if b.rect.collidepoint(mse)]\n                    for b in to_remove:\n                        blocklist.remove(b)\n\n                    if not to_remove:\n                        x=(int(mse[0]) \/ 32)*32\n                        y=(int(mse[1]) \/ 32)*32\n                        blocklist.append(Block(x+16,y+16))\n\n                elif event.button == 3:\n                    x=(int(mse[0]) \/ 32)*32\n                    y=(int(mse[1]) \/ 32)*32\n                    player=Player(x+16,y+16)\n\n    move = Move(key[K_UP], key[K_LEFT], key[K_RIGHT])\n\n    for b in blocklist:\n        screen.blit(b.sprite, b.rect)\n\n    if player:\n        player.update(move, blocklist)\n        screen.blit(player.sprite, player.rect)\n\n    clock.tick(60)\n    pygame.display.flip()\n<\/code><\/pre>\n<p>And here you can see loading and saving in action:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\" alt=\"enter image description here\"><\/p>\n<p>Note that you can&#8217;t save (or &#8220;pickle&#8221;) <code>Surfaces<\/code> this way. In this code, it works because the <code>Surfaces<\/code> of <code>Player<\/code> and <code>Block<\/code> are class variables, not instance variables, and thus don&#8217;t get saved to disk. If you want to &#8220;pickle&#8221; an object with a <code>Surface<\/code> instance variable, you would have to remove the <code>Surface<\/code> first (e.g. setting it to <code>None<\/code>) and load it again (e.g. in the <code>load<\/code> function).<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">2<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Save a list of objects on exit of pygame game [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Perfect! Right? Sadly, no. What you see here (&lt;__main__.Block object at 0x02416B70&gt;) is a typical string representation of a class instance. It&#8217;s just a simple string, and there&#8217;s no way to convert this string back to an instance of of Block. I assume you&#8217;re still on this game from your last question. So how &#8230; <a title=\"[Solved] Save a list of objects on exit of pygame game [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\" aria-label=\"More on [Solved] Save a list of objects on exit of pygame game [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[3716,554,349],"class_list":["post-19616","post","type-post","status-publish","format-standard","hentry","category-solved","tag-persistence","tag-pygame","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Perfect! Right? Sadly, no. What you see here (&lt;__main__.Block object at 0x02416B70&gt;) is a typical string representation of a class instance. It&#8217;s just a simple string, and there&#8217;s no way to convert this string back to an instance of of Block. I assume you&#8217;re still on this game from your last question. So how ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-07T01:00:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Save a list of objects on exit of pygame game [closed]\",\"datePublished\":\"2022-11-07T01:00:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\"},\"wordCount\":349,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\",\"keywords\":[\"persistence\",\"pygame\",\"python\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\",\"name\":\"[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\",\"datePublished\":\"2022-11-07T01:00:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Save a list of objects on exit of pygame game [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb","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:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb","og_description":"[ad_1] Perfect! Right? Sadly, no. What you see here (&lt;__main__.Block object at 0x02416B70&gt;) is a typical string representation of a class instance. It&#8217;s just a simple string, and there&#8217;s no way to convert this string back to an instance of of Block. I assume you&#8217;re still on this game from your last question. So how ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/","og_site_name":"JassWeb","article_published_time":"2022-11-07T01:00:47+00:00","og_image":[{"url":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif","type":"","width":"","height":""}],"author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Save a list of objects on exit of pygame game [closed]","datePublished":"2022-11-07T01:00:47+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/"},"wordCount":349,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"image":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage"},"thumbnailUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif","keywords":["persistence","pygame","python"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/","name":"[Solved] Save a list of objects on exit of pygame game [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage"},"image":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage"},"thumbnailUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif","datePublished":"2022-11-07T01:00:47+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#primaryimage","url":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/11\/Solved-Save-a-list-of-objects-on-exit-of-pygame.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-save-a-list-of-objects-on-exit-of-pygame-game-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Save a list of objects on exit of pygame game [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/19616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=19616"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/19616\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=19616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=19616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=19616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}