C-like assignment expression?

2008-05-21 Thread boblatest
Hello, I have an if-elif chain in which I'd like to match a string against several regular expressions. Also I'd like to use the match groups within the respective elif... block. The C-like idiom that I would like to use is this: if (match = my_re1.match(line): # use match elsif (match = my_re2

Filling in a tuple from unknown size list

2009-11-27 Thread boblatest
Hello all, (sorry for posting from Google. I currently don't have access to my normal nntp account.) Here's my question: Given a list of onknown length, I'd like to be able to do the following: (a, b, c, d, e, f) = list If the list has fewer items than the tuple, I'd like the remaining tuple el

Create a backslash-escaped version of a string?

2010-02-08 Thread boblatest
Hello, I'd like to have control characters in a string to be converted to their backslash-escaped counterparts. I looked in the encoders section of the string module but couldn't find anything appropriate. I could write it myself but I'm sure something of the sort exists. The hypothetical method "

Re: Create a backslash-escaped version of a string?

2010-02-08 Thread boblatest
On Feb 8, 12:28 pm, Chris Rebert wrote: > print a.encode("string-escape") How could I miss that? I was on that doc page already. Should have typed "/escape" in the browser ;-) Thanks, robert -- http://mail.python.org/mailman/listinfo/python-list