Re: bz2 module doesn't work properly with all bz2 files

2010-06-04 Thread Magdoll
On Jun 4, 3:05 pm, Cameron Simpson wrote: > On 04Jun2010 12:53, Magdoll wrote: > | I'm not sure what's causing this, but depending on the compression > | program used, the bz2 module sometimes exits earlier. > | > | I used pbzip2 to compress my bz2 files and read throu

bz2 module doesn't work properly with all bz2 files

2010-06-04 Thread Magdoll
I'm not sure what's causing this, but depending on the compression program used, the bz2 module sometimes exits earlier. I used pbzip2 to compress my bz2 files and read through the file using the bz2 module. The file descriptor always exits much earlier than where the actual EOF is. If I use bzip2

Re: tallying occurrences in list

2010-06-04 Thread Magdoll
On Jun 4, 11:33 am, Peter Otten <__pete...@web.de> wrote: > kj wrote: > > > Task: given a list, produce a tally of all the distinct items in > > the list (for some suitable notion of "distinct"). > > > Example: if the list is ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', > > 'c', 'a'], then the desired

Re: tallying occurrences in list

2010-06-04 Thread Magdoll
On Jun 4, 11:28 am, Paul Rubin wrote: > kj writes: > > 1. is there a standard name for it? > > I don't know of one, or a stdlib for it, but it's pretty trivial. > > > def tally(c): > >     t = dict() > >     for x in c: > >         t[x] = t.get(x, 0) + 1 > >     return sorted(t.items(), key=lambd

Re: file tell in a for-loop

2008-11-19 Thread Magdoll
Gotcha. Thanks! Magdoll On Nov 19, 2:57 am, Tim Chase <[EMAIL PROTECTED]> wrote: > Magdoll wrote: > > I was trying to map various locations in a file to a dictionary. At > > first I read through the file using a for-loop, buttell() gave back > > weird results, so I

file tell in a for-loop

2008-11-18 Thread Magdoll
e have any ideas as to why this is so? Thanks, Magdoll -- http://mail.python.org/mailman/listinfo/python-list

Re: segfault matplotlib with Python2.6

2008-11-17 Thread Magdoll
nd it failed, I just went for gnuplot and it worked. But now I'm using networkx which means plotting graphs requires matplotlib. Thanks, Magdoll On Nov 17, 3:23 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Mon, Nov 17, 2008 at 5:58 PM, Magdoll <[EMAIL PROTECTED]> wr

segfault matplotlib with Python2.6

2008-11-17 Thread Magdoll
Has anyone run into the same problem I have? I used to run matplotlib with Python2.5 and everything worked fine. Now I use Python2.6, and everything falls apart. I installed numpy, libpng, and freetype as required by matplotlib, and the installation all went well. But when I try to plot even the s

best way to host a membership site

2008-04-29 Thread Magdoll
ze time on trying to learn how to write an interface for users to register and manage their own space. Also I want an infrastructure that's not too rigid so if in the future I want to add more apps it's not to hard. I've also heard about django, but not enough to know how far it&#

psyco class question

2008-03-16 Thread Magdoll
n class types that can't be pickled or do I need to override something? Thanks in advance. Magdoll -- http://mail.python.org/mailman/listinfo/python-list

Re: merging intervals repeatedly

2008-03-12 Thread Magdoll
> Hi, > > The problem, as stated here, may have several solutions. For instance > the following set of intervals also satisfies the constraint: > (1,15), (20,40), (50,100) > > One question you should ask yourself is: do you want all solutions? or > just one? > If you want just one, there's another

Re: merging intervals repeatedly

2008-03-11 Thread Magdoll
On Mar 11, 11:01 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Tue, 11 Mar 2008 15:43:40 -0700 (PDT), Magdoll <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > Correct. I meant the final should be > > (1,30), (29,40), (50,100) &

Re: merging intervals repeatedly

2008-03-11 Thread Magdoll
Correct. I meant the final should be (1,30), (29,40), (50,100) On Mar 11, 3:41 pm, Magdoll <[EMAIL PROTECTED]> wrote: > Hi, > > I have to read through a file that will give me a bunch of intervals. > My ultimate goal is to produce a final set of intervals such that not > two

merging intervals repeatedly

2008-03-11 Thread Magdoll
Hi, I have to read through a file that will give me a bunch of intervals. My ultimate goal is to produce a final set of intervals such that not two intervals overlap by more than N, where N is a predetermined length. For example, I could read through this input: (1,10), (3,15), (20,30),(29,40),(5

different key, same value in dictionaries

2008-02-09 Thread Magdoll
Is there a cleaner way to do this example: d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30} The key is always a pair (x,y), but d[(x,y)] should have the same result as d[(y,x)]. So either I would have to store both d[(x,y)] and d[(y,x)] (unncessary extra space?), or write something like: if x <