Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Bob Gailer
At 10:12 AM 9/15/2005, Christopher Arndt wrote: Hi,I wonder if there is a shorter form of the following idiom:list1 = []list2 = []for item in original_list:    if condition(item):    list1.append(item)    else:    list2.append(item)Consider (5 lines instead of 7):lists = [[], []]for it

Re: [Tutor] Boa-Constructor

2005-09-15 Thread Luis N
> Luis, > > I was actually asking how usable Boa-Constructor is right now for project > purposes, since I had "heard" it was kind of unstable and crashes a lot. Is > that your experience with Boa-Constructor? Or was the information I found > misleading? > > Thanks, > Terry I found Boa-co

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Christopher Arndt
Alan G schrieb: > My personal approach would be two separate comprehensions(*) which > keeps the intent very clear and keeps it short at the expense > of iterating the original list twice. Of course this works only if condition(item) yields the same result each time it is called with the same in

Re: [Tutor] Please help with comparision in range of numbers

2005-09-15 Thread Danny Yoo
> 1427021_s_at chr7:102786983-102794499(+) > 1452285_a_at chr7:102786983-102794499(+) > 1445553_atchr7:102848766-102910961(-) > 1420925_atchr7:102863841-102887410(+) > 1450041_a_at chr7:102863841-102887410(+) > 1447553_x_at chr7:102899711-102899

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Alan G
>> [condition(i) and list1.append(i) or list2.append(i) for i in >> original] > > Hmm, no, this will always evaluate list2.append(i) because > the value of list1.append(i) is None. You could use > > [ (condition(i) and list1 or list2).append(i) for i in original ] Oops! Good point, which empha

[Tutor] Aschenputtel problem - Shorter is not better?

2005-09-15 Thread Terry Kemmerer
"Bearing in mind that shorter is not necessarily better..." Wouldn't shorter, as a rule of thumb, as in less language statements, mean fewer executions, and therefore faster? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mai

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread John Fouhy
On 16/09/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Alan Gauld wrote: > > Bearing in mind that shorter is not necessarily better... > > > > [condition(i) and list1.append(i) or list2.append(i) for i in > > original] > > Hmm, no, this will always evaluate list2.append(i) because the value of >

[Tutor] Please help with comparision in range of numbers

2005-09-15 Thread Srinivas Iyyer
Hello group, I have a data like this in tab-delim text. 1427021_s_atchr7:102786983-102794499(+) 1452285_a_atchr7:102786983-102794499(+) 1445553_at chr7:102848766-102910961(-) 1420925_at chr7:102863841-102887410(+) 1450041_a_atchr7:102863841-10

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Roel Schroeven
Alan Gauld schreef: >>I wonder if there is a shorter form of the following idiom: > > > Bearing in mind that shorter is not necessarily better... > > [condition(i) and list1.append(i) or list2.append(i) for i in > original] Alas, won't work. This is one of the cases where the ... and ... or ..

Re: [Tutor] running scripts with windows...slightly OT

2005-09-15 Thread George Flaherty
Yeah be careful with some of the cygwin tools. I had an issue with the jar command being picked up from cygwin/bin instead of JAVA_HOME and it was corrupting the contents of a jar file. -george -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of R. Alan Mon

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Kent Johnson
Alan Gauld wrote: >>I wonder if there is a shorter form of the following idiom: > > > Bearing in mind that shorter is not necessarily better... > > [condition(i) and list1.append(i) or list2.append(i) for i in > original] Hmm, no, this will always evaluate list2.append(i) because the value of

Re: [Tutor] running scripts with windows

2005-09-15 Thread R. Alan Monroe
>> Cygwin (http://www.cygwin.com/) It gives you a bash shell in >> Windows. > Actually it gives you a whole Unix environment including X Windows > and over 500 unix command line tools plus GNU C, sendmail, etc etc... Watch out, because cygwin-native python can conflict with win32 python, if the

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Alan Gauld
> I wonder if there is a shorter form of the following idiom: Bearing in mind that shorter is not necessarily better... [condition(i) and list1.append(i) or list2.append(i) for i in original] This returns a list of booleans that we throw away but the list1,list2 containers will have been modifi

Re: [Tutor] GETTING AN _.EXE VERSION OF _.PY program to run on a machine that does not have Python installed on it. (fwd)

2005-09-15 Thread Christopher Arndt
Danny Yoo schrieb: > > -- Forwarded message -- > Date: Wed, 14 Sep 2005 21:33:08 -0500 > From: JackA <[EMAIL PROTECTED]> > To: Danny Yoo <[EMAIL PROTECTED]> > Subject: Re: [Tutor] GETTING AN _.EXE VERSION OF _.PY program to run on a > machine that does not have Python installed

Re: [Tutor] GETTING AN _.EXE VERSION OF _.PY program to run on a machine that does not have Python installed on it. (fwd)

2005-09-15 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 14 Sep 2005 21:33:08 -0500 From: JackA <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] GETTING AN _.EXE VERSION OF _.PY program to run on a machine that does not have Python installed on it. Sorry for the boo boo b

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Kent Johnson
Christopher Arndt wrote: > Hi, > > I wonder if there is a shorter form of the following idiom: > > list1 = [] > list2 = [] > for item in original_list: > if condition(item): > list1.append(item) > else: > list2.append(item) I don't think so. You can write it as two list c

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Alan G
> for f, x in bunch_of_files, range(z): ... > Or maybe can I access the number of times the > loop has run? I think thats what enumerate does... >>> for x,y in enumerate([1,3,5]): ... print x,y ... 0 1 1 3 2 5 >>> Yep, looks like what you need. Alan G Author of the Learn to Program web

Re: [Tutor] running scripts with windows

2005-09-15 Thread Alan G
> Cygwin (http://www.cygwin.com/) It gives you a bash shell in > Windows. Actually it gives you a whole Unix environment including X Windows and over 500 unix command line tools plus GNU C, sendmail, etc etc... Alan G. ___ Tutor maillist - Tutor@py

Re: [Tutor] running scripts with windows

2005-09-15 Thread Alan G
If you are a Unix head using windows run to the cygwin site and install the whole caboodle. You'll think you are back in Unix land... If thats impossible them open a DOS boc (aka Command Prompt) and type python foo.py Or even just double click the file in Windows explorer... Alan G. - Or

[Tutor] Aschenputtel problem

2005-09-15 Thread Christopher Arndt
Hi, I wonder if there is a shorter form of the following idiom: list1 = [] list2 = [] for item in original_list: if condition(item): list1.append(item) else: list2.append(item) (optional step:) original_list[:] = list1 I call this the "Aschenputtel" problem, because it

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Ed Singleton
Wonderful, thank you all of you. zip, enumerate, and count seem to do everything I want, though I do think for f, x in bunch_of_files, range(z): is a little more intuitive than for f, x in zip(bunch_of_files, range(z)): Thanks Ed On 15/09/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Sing

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Kent Johnson
Ed Singleton wrote: > I roughly want to be able to do: > > for f, x in bunch_of_files, range(z): > > so that x iterates through my files, and y iterates through something else. > > Is this something I can do? In the general case use zip(): for f, x in zip(bunch_of_files, range(z)): In this cas

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Pierre Barbier de Reuille
You have a much simpler solution ! As this is a most common task to iterate on a sequence while keeping track of the index, there is an object just for that : for i,x in enumerate(iterable): # Here "i" is the index and "x" the element Also, to get some "advance" iteration schemes, have a lot at

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Andre Engels
On 9/15/05, Ed Singleton <[EMAIL PROTECTED]> wrote: > I roughly want to be able to do: > > for x, y in bunch_of_files, range(z): > > so that x iterates through my files, and y iterates through something else. > > Is this something I can do? It's not fully clear to me what you want to do. Do you

Re: [Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Pujo Aji
assume: you have two list with the same size L1 = [1,2,3] L2 = [11,22,33]   you can zip the L1 and L2 into L L = zip(L1,L2)  # L = [(1,11),(2,22),(3,33)]    then you can process: for x in L:   dosomething(x[0])...   dosomething(x[1])...   I'm not so sure about your problem but If you want to do som

[Tutor] Multiple Simultaneous Loops

2005-09-15 Thread Ed Singleton
I roughly want to be able to do: for f, x in bunch_of_files, range(z): so that x iterates through my files, and y iterates through something else. Is this something I can do? If so, what would be the best way to create a range of indeterminate length? If not, is there a nice way I can do it, r