Re: Store a variable permanently

2013-03-13 Thread Chris Angelico
On Thu, Mar 14, 2013 at 4:37 AM, Steven D'Aprano wrote: > On Tue, 12 Mar 2013 12:54:11 +0100, Jean-Michel Pichavant wrote: > >>> > import pickle >>> > a = 758 >>> > pickle.dump(a, open('test.pickle', 'w')) >>> > !cat test.pickle >>> > I758 >>> > . >>> >>> >>> What is that? It's not Python code, !c

Re: Store a variable permanently

2013-03-13 Thread Jean-Michel Pichavant
- Original Message - > On Tue, 12 Mar 2013 12:54:11 +0100, Jean-Michel Pichavant wrote: > > >> > import pickle > >> > a = 758 > >> > pickle.dump(a, open('test.pickle', 'w')) > >> > !cat test.pickle > >> > I758 > >> > . > >> > >> > >> What is that? It's not Python code, !cat test.pickle g

Re: Store a variable permanently

2013-03-13 Thread Steven D'Aprano
On Tue, 12 Mar 2013 12:54:11 +0100, Jean-Michel Pichavant wrote: >> > import pickle >> > a = 758 >> > pickle.dump(a, open('test.pickle', 'w')) >> > !cat test.pickle >> > I758 >> > . >> >> >> What is that? It's not Python code, !cat test.pickle gives a syntax >> error. > > It's a IPython shell

Re: Store a variable permanently

2013-03-12 Thread Jean-Michel Pichavant
- Original Message - > On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote: > > [...] > > While your point about security is fair, the others aren't. Pickle > > uses > > by default an ascii representation of the data, it's readable and > > writeable. > > > > import pickle > >

Re: Store a variable permanently

2013-03-12 Thread Steven D'Aprano
On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote: [...] > While your point about security is fair, the others aren't. Pickle uses > by default an ascii representation of the data, it's readable and > writeable. > > import pickle > a = 758 > pickle.dump(a, open('test.pickle', 'w'))

Re: Store a variable permanently

2013-03-11 Thread Jean-Michel Pichavant
- Original Message - > On Fri, 01 Mar 2013 11:19:22 +0100, Jean-Michel Pichavant wrote: > > > - Original Message - > >> So i have a variable called funds that i want to store the value > >> of > >> even after the program is exited. My funds variable holds the > >> total > >> valu

Re: Store a variable permanently

2013-03-01 Thread Steven D'Aprano
On Fri, 01 Mar 2013 11:19:22 +0100, Jean-Michel Pichavant wrote: > - Original Message - >> So i have a variable called funds that i want to store the value of >> even after the program is exited. My funds variable holds the total >> value of funds i have. I add a certain number of funds ea

Re: Store a variable permanently

2013-03-01 Thread Roy Smith
In article <51315957$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Fri, 01 Mar 2013 07:42:38 -0700, Michael Torrie wrote: > > > Another solution is to use a database system. Either SQLite > > (file-based) or something server-based like PosgreSQL or MariaDB. > > The

Re: Store a variable permanently

2013-03-01 Thread Modulok
>> Installing and running a database for a single integer is like using a >> using a bulldozer for moving your keyboard half an inch to the left. I'd like to see that sometime XD -Modulok- -- http://mail.python.org/mailman/listinfo/python-list

Re: Store a variable permanently

2013-03-01 Thread Steven D'Aprano
On Fri, 01 Mar 2013 07:42:38 -0700, Michael Torrie wrote: > Another solution is to use a database system. Either SQLite > (file-based) or something server-based like PosgreSQL or MariaDB. The data in this case is a single integer value. Installing and running a database for a single integer is

Re: Store a variable permanently

2013-03-01 Thread Michael Torrie
On 03/01/2013 03:19 AM, Jean-Michel Pichavant wrote: > I would serialize the data. > > http://docs.python.org/2/library/pickle.html > > funds=5 pickle.dump(funds, 'funds.pickle') > > # to reload funds: > > funds = pickle.load('funds.pickle') > > > The good thing with pickle is that it seriali

Re: Store a variable permanently

2013-03-01 Thread Jean-Michel Pichavant
- Original Message - > So i have a variable called funds that i want to store the value of > even after the program is exited. My funds variable holds the total > value of funds i have. I add a certain number of funds each time i > run the program by entering how much i want to add. How wou

Re: Store a variable permanently

2013-02-28 Thread Mitya Sirenef
On 02/28/2013 10:35 PM, eli m wrote: So i have a variable called funds that i want to store the value of even after the program is exited. My funds variable holds the total value of funds i have. I add a certain number of funds each time i run the program by entering how much i want to add. Ho

Re: Store a variable permanently

2013-02-28 Thread Steven D'Aprano
On Thu, 28 Feb 2013 19:35:57 -0800, eli m wrote: > So i have a variable called funds that i want to store the value of even > after the program is exited. My funds variable holds the total value of > funds i have. I add a certain number of funds each time i run the > program by entering how much i

Store a variable permanently

2013-02-28 Thread eli m
So i have a variable called funds that i want to store the value of even after the program is exited. My funds variable holds the total value of funds i have. I add a certain number of funds each time i run the program by entering how much i want to add. How would i store the funds variable to k