Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3236128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:35:10+00:00 2026-05-17T17:35:10+00:00

I am trying to a save a list into a file in a way

  • 0

I am trying to a save a list into a file in a way that when I load and read the file again I get my lists as they are. In other words,the datatype doesn’t change while saving and loading. Because right now, I use “write” to save my list into a file, and when I try to load it back into memory I get strings rather than real lists. is there a way to convert them back to lists after loading? or should I change the way I save my lists into a file.Please note that I don’t want to use Pickle.
Thanks
EDIT: my problem with pickle is that I have to add my lists step by step in different part of the code.Thus, I don’t have all the lists at once so I can pickle them. This is the problem that I had.It gives me wrong answer, I guess it is because pickle requires all the info in one place and adds them to file at once. (?)
I have only integers in my lists.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:35:11+00:00Added an answer on May 17, 2026 at 5:35 pm

    If your data is only a list whose items are basic types (e.g. str, unicode, int, float) and lists or dicts whose elements are etc etc, then you can use json; this is portable across languages (is that your problem with pickle?).

    Update after question edited “””my problem with pickle is that I have to add my lists step by step in different part of the code”””

    Have you considered gathering the lists to be pickled as you find them and then pickling all of them at once at the end? Same applies with json etc. All you need is a container to keep your lists in. You can make this look nicer by putting it in a class e.g.

    class Preserver(object):
        def __init__(self):
            self._bottle = []
        def add(self, an_object):
            self._bottle.append(an_object)
        def preserve(self, filepath):
            # code using pickle or json to push self._bottle
            # out to a file named "filepath"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to load a text file into a combobox, and then
I am trying to load a CSV file into an array using ColdFusion (version
I am using asp.net and I am trying to save checkbox values into a
I have an asp.net app and I am trying to save a text file
I'm trying to implement a Load / Save function for a Windows Forms application.
I'm trying to figure out the best way to save a simple one-to-many relationship
Let's say you have a List<List<Boolean>> and you want to encode that into binary
I'm trying to build a Chrome browser extension, that should enhance the way the
I ran into a rather annoying issue with the list of open devices, trying
Im trying to save a bitmap jpg format with a specified encoding quality. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.