Linked Questions
13 questions linked to/from How do I save and restore multiple variables in python?
1
vote
1
answer
12k
views
Save variables in Python [duplicate]
My question is regarding saving values of variables in Python. More specifically I have two different scripts that calculate the same things with 2 different ways. What I want to do is to compare the ...
0
votes
1
answer
79
views
How do I keep a list from resetting whenever the code runs (Python) [duplicate]
I was trying to improve this little code by adding a tasks history option but I failed miserably. Whenever I run the code the tasks3 list resets. What can I do to save the recent tasks?
import random
...
347
votes
3
answers
151k
views
Using pickle.dump - TypeError: must be str, not bytes
I'm using python3.3 and I'm having a cryptic error when trying to pickle a simple dictionary.
Here is the code:
import os
import pickle
from pickle import *
os.chdir('c:/Python26/progfiles/')
def ...
5
votes
3
answers
10k
views
TypeError: 'str' does not support the buffer interface
i post from my original code,
crystal = open('vmises.dat','r')
crystalincrement = pickle.load(crystal)
crystaldir = pickle.load(crystal)
crystalface = pickle.load(crystal)
crystal.close()
Error is,...
4
votes
2
answers
2k
views
Restore objects from pickled file by name in python
Using Python 2.7.
Is there a way to restore only specified objects from a pickle file?
using the same example as a previous post:
import pickle
# obj0, obj1, obj2 are created here...
# Saving the ...
1
vote
3
answers
608
views
In a pickle with pickling in python
I have gone through this website and many others but no one seems to give me the simplest possible answer. In the scrip bellow there are 2 different variables that need to be placed into a single ...
-1
votes
1
answer
1k
views
How to get variable values from previous run in terminal?
Let's say I have a simple python script math_ops.py as follows:
a = 5
b = 4
c = 7
d = a + b
e = b - c
print(d)
I run this script in the Ubuntu terminal as $ python math_ops.py, which prints the value ...
1
vote
3
answers
450
views
Plain-text, Python-syntax file to save and restore some class variables?
In my case, I'd like to save and restore some "plain" variables (i.e., ints, strings) in a file, which would end up as class properties. This example is the closest I got, by using import:
a.py
b = ...
1
vote
1
answer
538
views
Python: Transferring two byte variables with a binary file
Let's say I have two bytearray,
b = bytearray(b'aaaaaa')
b1 = bytearray(b'bbbbbb')
file_out = open('bytes.bin', 'ab')
file_out.write(b)
file_out.write(b1)
this code will create a .bin file which ...
1
vote
2
answers
179
views
Simple Python Coding: How do I use text files as variables?
How can I make changeable variables in other files via my primary Python file, then change them?
I want to be able to make a change in my main python file, and then have it carry over into the text ...
1
vote
2
answers
173
views
Saving values in python
New to programming and have just written my first program in Python. The program works well in the initial steps but whatt I'm not sure about is how to store values so the next time the programm is ...
-1
votes
1
answer
116
views
TensorFlow saver - Saving an ordinary Python variable
When using TensorFlow Saver, is there a way to save an ordinary Python variable as well?
If not, what is the best solution when certain Python vars are helpful to save.
0
votes
1
answer
70
views
write and read lists from/to file in python
How to write, then read, (conserving all specifics) of the following list, in python?
Using various methods, I could not read the data back with the exact same formatting, datatypes, etc. I'm using ...