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
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
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
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
right, i forgot about that...
--
http://mail.python.org/mailman/listinfo/python-list
> 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
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
>>> 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
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