Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to save a class object to a file?
i was using json to save some data for my game. While I was trying to save I noticed I got an error on serializing the Player class. I could save all the stats of the player, but that would be a hassle. Is there a way I can save the Player class to a file.
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Pickle or Shelve.

If it's just one object (the player), then Pickle. Shelve is sort of like a dictionary interface for using Pickle with a lot of different things.
metulburr likes this post
It should be noted that pickling can be dangerous. If you are just using it for a local game, then you dont have to worry about anything.
micseydel likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Save a file uploaded from client-side without having to read into memory andym118 3 257 Nov-21-2019, 07:34 AM
Last Post: DeaD_EyE
  Details of attachment files in a msg file such as file names save into a python list klllmmm 2 295 Nov-12-2019, 05:59 AM
Last Post: klllmmm
  Read each line, replace string and save into a new file igormonteiro 2 334 Sep-15-2019, 01:24 PM
Last Post: buran
  save content of table into file atlass218 10 550 Aug-28-2019, 12:12 PM
Last Post: Gribouillis
  class returns NoneType Object istemihan 0 235 Aug-12-2019, 11:47 AM
Last Post: istemihan
  Object and type class Uchikago 2 233 Jul-28-2019, 10:35 AM
Last Post: DeaD_EyE
  How to save latest time stamp in a file? redwood 12 1,138 Jul-11-2019, 11:03 AM
Last Post: redwood
  Return a value when I equal an object from a class ihouses 4 351 Jul-10-2019, 02:44 AM
Last Post: SheeppOSU
  Save console output to text file (like a log) koticphreak 9 1,181 Jun-02-2019, 07:45 PM
Last Post: snippsat
  saving (in text or binary) an object under a defined class cai0824 3 455 May-12-2019, 08:55 AM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)