Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread David Hutto
> Separately, I'm also curious about how to process big files. For example, I > was trying to play 100 million games of chutes & ladders Without doing the 100,000,000, you could try either researching the nums, or trying an algorithm that tried intervals, and narrowed down the best , and numerical

Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread Danny Yoo
> Separately, I'm also curious about how to process big files. For example, I > was trying to play 100 million games of chutes & ladders, and I crashed my > machine, I believe: the game results, including 4 ints & 2 short lists of > ints per game, are gathered into a list, so it can become a pretty

Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread eryksun
On Thu, Jan 2, 2014 at 4:15 AM, Keith Winston wrote: > Thanks for all this Eryksun (and Mark!), but... I don't understand why you > brought gdbm in? Is it something underlying shelve, or a better approach, or > something else? That last part really puts me in a pickle, and I don't > understand why

Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread Steven D'Aprano
On Thu, Jan 02, 2014 at 04:15:06AM -0500, Keith Winston wrote: > Separately, I'm also curious about how to process big files. For example, I > was trying to play 100 million games of chutes & ladders, and I crashed my > machine, I believe: the game results, including 4 ints & 2 short lists of > in

Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread Keith Winston
Thanks for all this Eryksun (and Mark!), but... I don't understand why you brought gdbm in? Is it something underlying shelve, or a better approach, or something else? That last part really puts me in a pickle, and I don't understand why. Separately, I'm also curious about how to process big files

Re: [Tutor] Shelve & immutable objects

2014-01-01 Thread eryksun
On Wed, Jan 1, 2014 at 11:43 AM, Keith Winston wrote: > Thanks Danny, I don't understand the re-persisted part, but I'll look into > it. Shelf.close calls Shelf.sync to flush the cache. Here's what it does: >>> print(inspect.getsource(shelve.Shelf.sync)) def sync(self): i

Re: [Tutor] Shelve & immutable objects

2014-01-01 Thread Mark Lawrence
On 01/01/2014 16:43, Keith Winston wrote: Thanks Danny, I don't understand the re-persisted part, but I'll look into it. I realized I hadn't done enough homework to justify a question right after I sent the first half of that one! Happy New Year! You do infinitely more work than some who pose

Re: [Tutor] Shelve & immutable objects

2014-01-01 Thread Keith Winston
Thanks Danny, I don't understand the re-persisted part, but I'll look into it. I realized I hadn't done enough homework to justify a question right after I sent the first half of that one! Happy New Year! ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] Shelve & immutable objects

2013-12-31 Thread Danny Yoo
On Tue, Dec 31, 2013 at 11:01 PM, Keith Winston wrote: > I'm working my way slowly through Programming Python by Mark Lutz, and as an > example of data persistence, he uses this example: Ooops; the email got cut off a bit early. Can you try again? ___

Re: [Tutor] Shelve & immutable objects

2013-12-31 Thread Danny Yoo
According to: http://docs.python.org/2/library/shelve.html The shelve can be opened in 'writeback' mode, which I think might be relevant to your question. "By default modified objects are written only when assigned to the shelf (see Example). If the optional writebackparameter is set to True,

Re: [Tutor] Shelve & immutable objects

2013-12-31 Thread Keith Winston
So sorry, I hit return: here's the example: import shelve db = shelve.open('class-shelve') sue = db['sue'] sue.giveRaise(.25) db['sue'] = sue tom = db['tom'] tom.giveRaise(.20) db['tom'] = tom db.close() Is it possible to dispense with the assignment/reassignment and just use (open shelve) db[

[Tutor] Shelve & immutable objects

2013-12-31 Thread Keith Winston
I'm working my way slowly through Programming Python by Mark Lutz, and as an example of data persistence, he uses this example: -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mail