Re: Most compact "X if X else Y" idiom

2008-10-11 Thread jbperez808
Thanks, folks. Short-circuit boolean was the syntax I had in mind which momentarily escaped me, but the "if not x: x='blah'" idiom was instructive as well. -- http://mail.python.org/mailman/listinfo/python-list

Most compact "X if X else Y" idiom

2008-10-11 Thread jbperez808
I find myself having to do the following: x = (some complex expression) y = x if x else "blah" and I was wondering if there is any built-in idiom that can remove the need to put (some complex expression) in the temporary variable x. e.g. something like the below: y= foobar ((some complex e

Re: slicing functionality for strings / Python suitability forbioinformatics

2005-09-19 Thread jbperez808
Great suggestion... I was naively trying to turn the string into a list and slice that which I reckon would be significantly slower. -- http://mail.python.org/mailman/listinfo/python-list

Re: slicing functionality for strings / Python suitability forbioinformatics

2005-09-19 Thread jbperez808
Having to do an array.array('c',...): >>> x=array.array('c','ATCTGACGTC') >>> x[1:9:2]=array.array('c','') >>> x.tostring() 'AACAGACATC' is a bit klunkier than one would want, but I guess the efficient performance is the silver lining here. -- http://mail.python.org/mailman/listinfo

Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread jbperez808
right, i forgot about that... -- http://mail.python.org/mailman/listinfo/python-list

Re: slice lists

2005-09-19 Thread jbperez808
> Lists are one-dimensional. They can only take one slice, not two. Ah ok, I thought l[3:4,5:8] would return [3,5,6,7] -- http://mail.python.org/mailman/listinfo/python-list

slice lists

2005-09-19 Thread jbperez808
Reading: http://docs.python.org/ref/slicings.html it would seem to indicate that the ff will work: L=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] however, you get: >>> l[3:4:,5:8:] Traceback (most recent call last): File "", line 1, in ? l[3:4:,5:8:] TypeError: list indices must be integ

slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread jbperez808
>>> rs='AUGCUAGACGUGGAGUAG' >>> rs[12:15]='GAG' Traceback (most recent call last): File "", line 1, in ? rs[12:15]='GAG' TypeError: object doesn't support slice assignment You can't assign to a section of a sliced string in Python 2.3 and there doesn't seem to be mention of this as a Python

Re: Wheel-reinvention with Python

2005-08-15 Thread jbperez808
Torsten Bronger wrote: > I've been having a closer look at wxPython which is not Pythonic at > all and bad documented. Probably I'll use it nevertheless. Aye. Couldn't agree more. > PyGTK and PyQt may have their own advantages and disadvantages. I like PyGTK because the calls are C-based and