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

Re: [Tutor] Shelve

2010-02-11 Thread Randy Raymond
Ok, I see that is was the directory restriction that was the problem. Sorry for the simple question. Randy Raymond From: Randy Raymond Sent: Thursday, February 11, 2010 10:09 AM To: Tutor Python Subject: [Tutor] Shelve I am running Python 2.6.4 under Windows Vista 32-bit Home Edition

Re: [Tutor] Shelve

2010-02-11 Thread Sander Sweers
On do, 2010-02-11 at 10:09 -0600, Randy Raymond wrote: > I am running Python 2.6.4 under Windows Vista 32-bit Home Edition. > When I run: > > import shelve > test=shelve.open("myTest.fil") And to shich directory does this file get written? I suspect you are writing to a protected directory. When

[Tutor] Shelve

2010-02-11 Thread Randy Raymond
I am running Python 2.6.4 under Windows Vista 32-bit Home Edition. When I run: import shelve test=shelve.open("myTest.fil") I get a DCPermissionerror exception. I am an administrator on this machine (it is my home PC). Python and Pythonw are both allowed exceptions to the Windows firewall.

Re: [Tutor] Shelve doesn't free up memory

2009-03-31 Thread Emile van Sebille
Timo wrote: Emile van Sebille schreef: Timo wrote: # Results file import shelve def read_result(person): results = [] s = shelve.open(RESULTFILE) try: results = s[person] Maybe passing this out prevents s from being garbage collected? What do you mean by passing out?

Re: [Tutor] Shelve doesn't free up memory

2009-03-31 Thread Timo
Emile van Sebille schreef: Timo wrote: # Results file import shelve def read_result(person): results = [] s = shelve.open(RESULTFILE) try: results = s[person] Maybe passing this out prevents s from being garbage collected? What do you mean by passing out? I also tried

Re: [Tutor] Shelve doesn't free up memory

2009-03-30 Thread Emile van Sebille
Timo wrote: # Results file import shelve def read_result(person): results = [] s = shelve.open(RESULTFILE) try: results = s[person] Maybe passing this out prevents s from being garbage collected? Emile except KeyError: #print "No results for this person"

[Tutor] Shelve doesn't free up memory

2009-03-30 Thread Timo
Hello, I have a PyGTK application where the user is able to click on a button, then a new dialog pops up with a treeview and the program fills this view with data from a shelve. Everything works, the data is being added to the treeview. The only problem is, that when I close the dialog, it doesn

Re: [Tutor] Shelve: remove dictionary from list

2009-03-04 Thread Timo
Kent Johnson schreef: On Tue, Mar 3, 2009 at 12:18 PM, Timo wrote: Hello all, I'm using the Shelve module to store dictionaries in a list as a value of a key. So: key = [{'keyA' : 1, 'keyB' : 2}, {'key1' : 1, 'key2' : 2}] The problem is I can't remove a dictionary from the list. import

Re: [Tutor] Shelve: remove dictionary from list

2009-03-03 Thread Kent Johnson
On Tue, Mar 3, 2009 at 12:18 PM, Timo wrote: > Hello all, I'm using the Shelve module to store dictionaries in a list as a > value of a key. > > So: > > key = [{'keyA' : 1, 'keyB' : 2}, {'key1' : 1, 'key2' : 2}] > > The problem is I can't remove a dictionary from the list. > > > import shelve > >

[Tutor] Shelve: remove dictionary from list

2009-03-03 Thread Timo
Hello all, I'm using the Shelve module to store dictionaries in a list as a value of a key. So: key = [{'keyA' : 1, 'keyB' : 2}, {'key1' : 1, 'key2' : 2}] The problem is I can't remove a dictionary from the list. import shelve s = shelve.open('file') try: for index, value in enumerate(s[

Re: [Tutor] Shelve problem

2007-08-08 Thread Terry Carroll
On Wed, 8 Aug 2007, TheSarge wrote: > I have five data files, that are used to build a database. > > 1.txt > 2.txt > 3.txt > 4.text > 5.txt > > I want to build a database using a persistent dictionary (shelve). > > The specifications are that the key for each dictionary keyword pair, is the > l

[Tutor] Shelve problem

2007-08-08 Thread TheSarge
I have five data files, that are used to build a database. 1.txt 2.txt 3.txt 4.text 5.txt I want to build a database using a persistent dictionary (shelve). The specifications are that the key for each dictionary keyword pair, is the lefthand side value of the # sign, and the corresponding val

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Andreas Kostyrka wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Eric Brunson wrote: > >> On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: >> >>> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) >>> >>> Barton David wrote: > *sigh* I'm

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote > On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: >>> In what way is it Python's fault that the dbm database doesn't >>> reclaim >>> disk space? >> >> It's actually how most databases work. Even a simple Outlook pst >> file >> (which is a database, t

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Eric Brunson wrote: > On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: >> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) >> >>> Barton David wrote: >>> *sigh* I'm really going off Python. >>> In what way is it Python's fault that the

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: > * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) > >> Barton David wrote: >> >>> *sigh* I'm really going off Python. >>> >> >> In what way is it Python's fault that the dbm database doesn't reclaim >> disk space? > > It's actually how most data

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Thorsten Kampe
* Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) > Barton David wrote: > > *sigh* I'm really going off Python. > > In what way is it Python's fault that the dbm database doesn't reclaim > disk space? It's actually how most databases work. Even a simple Outlook pst file (which is a database, too

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Alan Gauld wrote: > "Andreas Kostyrka" <[EMAIL PROTECTED]> wrote > > >>> a lot to build the Tacoma Narrows bridge... Similarly you don't >>> need >>> much math to build a GUI friont end to a database, but you need >>> >> I would question even that one can write a good GUI frontend to a >

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Alan Gauld
"Andreas Kostyrka" <[EMAIL PROTECTED]> wrote >> a lot to build the Tacoma Narrows bridge... Similarly you don't >> need >> much math to build a GUI friont end to a database, but you need > > I would question even that one can write a good GUI frontend to a > database without the theory behind it.

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Kent Johnson
Andreas Kostyrka wrote: > Believe me, the Python developers are sure listening. Only that > "cleaning up the mess" has associated costs, that are usually not > acceptable. If it comes to "not breaking existing programs" or "cleaning > up the stdlib so it's nicer", "not breaking existing programs"

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Barton David wrote: > Eric Brunson wrote: >> You seem like a smart guy that's having a bad day, so I'm cutting you >> slack. > > Thanks Eric. Yes I did indeed have a bad day (and it got much much worse), > and this is most definitely a case of a ba

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
Python is like democracy. It isn't perfect, but it's the best thing come up with so far. ;-) Barton David wrote: > Eric Brunson wrote: > > You seem like a smart guy that's having a bad day, so I'm cutting you > > slack. > > Thanks Eric. Yes I did indeed have a bad day (and it got much much

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
Eric Brunson wrote: > You seem like a smart guy that's having a bad day, so I'm cutting you > slack. Thanks Eric. Yes I did indeed have a bad day (and it got much much worse), and this is most definitely a case of a bad workman blaming his tools. I apologise to all concerned for voicing my frustr

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Tiger12506
>> cPickle/Pickle question is AFAIR documented, > > But not in a manner totally clear to a newbie. An experienced > programmer will figure out that a C implementation is faster but > what does that meabn when your only reference is a few weeks > of Python? And why is there two modules if one is bet

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alan Gauld wrote: > "Andreas Kostyrka" <[EMAIL PROTECTED]> wrote > >> was, that the only way to have more math courses would be to study >> something with mathematics in the title *g*) > > Thats true of most engineering courses. > Although I studie

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Alan Gauld
"Andreas Kostyrka" <[EMAIL PROTECTED]> wrote > was, that the only way to have more math courses would be to study > something with mathematics in the title *g*) Thats true of most engineering courses. Although I studied Electrical engineering the only compulsory subject for each of the 5 years(i

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alan Gauld wrote: > "Tiger12506" <[EMAIL PROTECTED]> wrote > >> Some people need degrees, most people don't. It all depends on what >> they are >> capable of understanding. > > It also depends what they are doing. > Most programmers don't build c

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
One thing I don't think people realize, or at least don't talk about often enough, is that good programming, like good art, takes talent. I can draw a cat to make my 2yo happy or sketch my house well enough that someone could pick it out driving down the street, but if I paint every day for th

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote > Some people need degrees, most people don't. It all depends on what > they are > capable of understanding. It also depends what they are doing. Most programmers don't build complex state machines, nor do they build safety critical systems. 90% or more of

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote >> newbie-friendly. My only complaint is that I'm starting to feel >> like I >> won't get much further than that without a computer science degree. > > I'll disagree with you on that, if you can get a PhD in genetics > then > programming should be a snap.

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote > It seems like new programmers today expect to be spoonfed their > information like they were in grammar school. I think its true they expect a lot of tutorial stuff, probably because of the number of idiot guides to programming in languages like VB/PHP e

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Alan Gauld
"Barton David" <[EMAIL PROTECTED]> wrote > I've learned to program with Python (and can hardly conceive of a > better > language to be honest)- and I still think the core language is > great: > elegant, easy to use and brilliantly documented. Completely agree. > But the more I explore the stan

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Tiger12506
> ...some credit. I taught myself to program, from scratch, without access > to (or time for) any courses whatsoever... 5 years now...core > language...certain standard modules pretty well... complaint...won't get > much further...without a computer science degree. Wow. I'm so *shocked*. Most p

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
Barton David wrote: > > *Eric Brunson* wrote: > > > It seems like new programmers today expect to be spoonfed their > > information like they were in grammar school. They don't know what it > > is to hack a Makefile to get a package to compile or break out an > RFC to > > understand a protocol.

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
Eric Brunson wrote: > It seems like new programmers today expect to be spoonfed their > information like they were in grammar school. They don't know what it > is to hack a Makefile to get a package to compile or break out an RFC to > understand a protocol. If you don't understand something a

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
the code you'd have to read is just more Python, anyway. Just me being a grouchy old programmer. In my day we had to program in 4 feet of snow, uphill... both ways! > Andreas > > >> >> >> -Original Message- >> From: Kent Johnson [mailto:[EMAIL

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
Andreas Kostyrka wrote: > Additionally, the language core is very very thought out, with glacial > enhancements. "Fixing" the standard library OTOH would involve renaming > and removing names, which would make huge collections of programs break. > Not a good thing :( Yes agreed. My comments there

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Kent Johnson
once seemed to aspired to. > > > > -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: 27 July 2007 14:11 > To: Barton David > Cc: tutor@python.org > Subject: Re: [Tutor] Shelve del not reducing file size > > If it's any sol

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Andreas Kostyrka
d involve renaming and removing names, which would make huge collections of programs break. Not a good thing :( Andreas I know no language that beats this pattern. > > > > -Original Message----- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: 27 July 2007 14:11 >

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
27;friendliness' it once seemed to aspired to. -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: 27 July 2007 14:11 To: Barton David Cc: tutor@python.org Subject: Re: [Tutor] Shelve del not reducing file size If it's any solace, there is a small minority of Pyth

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Andreas Kostyrka
reas > > > -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: 27 July 2007 13:07 > To: Barton David > Cc: tutor@python.org > Subject: Re: [Tutor] Shelve del not reducing file size > > Barton David wrote: >> *sigh* I'm r

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Kent Johnson
; > I guess it's not Python's fault: I'm guess I'm just too stupid. But I'm > just getting really disenchanted. Sorry. > > > -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: 27 July 2007 13:07 > To: Barton Dav

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
too stupid. But I'm just getting really disenchanted. Sorry. -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: 27 July 2007 13:07 To: Barton David Cc: tutor@python.org Subject: Re: [Tutor] Shelve del not reducing file size Barton David wrote: > *sigh* I'm really

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Kent Johnson
Barton David wrote: > *sigh* I'm really going off Python. In what way is it Python's fault that the dbm database doesn't reclaim disk space? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
*sigh* I'm really going off Python. OK, thanks Andreas. This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University o

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 That's in the nature of the underlying database library used for the shelve. Most dbm implemention on Unix are using a sparse file that is used as hashmap. E.g. compare ls -l versus du of the database file. Now if this is the case, there is no way (wi

[Tutor] Shelve del not reducing file size

2007-07-27 Thread Barton David
Hi, I've hit a snag with Python's shelve module. By way of example... _ from shelve import DbfilenameShelf as StoreFile import os sf=StoreFile("mytest.db",writeback=False) # but same problem if writeback=True for i in range(1): sf[str(i)]="TESTOBJECT" sf.sync() print len(sf) sf.cl