Re: Fast powerset function

2007-07-13 Thread Jyotirmoy Bhattacharya
On Jul 13, 6:34 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > def recursive_powerset(s): > if not s: yield set() > for x in s: > s2 = s - set([x]) > for subset in recursive_powerset(s2): > yield subset > yield subset.union(set([x])) > Your recursive_

Re: diferent answers with isalpha()

2007-07-12 Thread Jyotirmoy Bhattacharya
On Jul 13, 5:05 am, [EMAIL PROTECTED] wrote: > In Idle when I do print 'รก'.isalpha() I get True. When I make and > execute a script file with the same code I get False. > > Why do I have diferent answers ? Non-ASCII characters in ordinary (8-bit) strings have all kinds of strangeness. First, the a

Re: Timing a python program run

2007-07-07 Thread Jyotirmoy Bhattacharya
On Jul 8, 12:21 am, David <[EMAIL PROTECTED]> wrote: > Hi, > > In matlab, I'd calculate the time for a script named test.m to run > with: > > >> tic, run, toc > > Is there some way to do this in python on a mac os x from the terminal > window? Or whatever? The timeit module may be of use: http://d

Re: Extracting arbitrary amounts of data from a dictionary.

2007-07-05 Thread Jyotirmoy Bhattacharya
On Jul 6, 2:21 am, Jyotirmoy Bhattacharya <[EMAIL PROTECTED]> wrote: > On Jul 6, 12:31 am, [EMAIL PROTECTED] wrote: > > > > > I had nothing better to do, so I thought I would make a database that > > contained the songs played on the internet radio station I list

Re: Extracting arbitrary amounts of data from a dictionary.

2007-07-05 Thread Jyotirmoy Bhattacharya
On Jul 6, 12:31 am, [EMAIL PROTECTED] wrote: > I had nothing better to do, so I thought I would make a database that > contained the songs played on the internet radio station I listen to > (hardradio.com) so I could see how many differents songs/artists they > played. > So I end up with a the num

Re: nested list comprehension and if clauses

2007-06-27 Thread Jyotirmoy Bhattacharya
On Jun 28, 10:53 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Jyotirmoy Bhattacharya <[EMAIL PROTECTED]> wrote: > > print [(m,n) for m in range(5) for n in multab(m) if m>2] > > I was wondering if there is some way to write the if-clause so that it > > is 'hoi

nested list comprehension and if clauses

2007-06-27 Thread Jyotirmoy Bhattacharya
I'm a newcomer to Python. I have just discovered nested list comprehensions and I need help to understand how the if-clause interacts with the multiple for-clauses. I have this small program: def multab(n): print 'multab',n return [n*i for i in range(5)] print [(m,n) for m in range(5) for