Exception-handling

2006-02-24 Thread Odd-R.
I have come over a strange problem regarding exceptions This is my code: try: #some operation except Exception, info: #some message except: #?? When executing my code, I get to the last block here. This I find rather strange, because I thought Exception would catch all exceptions. But this

Comparing lists

2005-10-10 Thread Odd-R.
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements that are in

error when parsing xml

2005-09-05 Thread Odd-R.
I use xml.dom.minidom to parse some xml, but when input contains some specific caracters(æ, ø and å), I get an UnicodeEncodeError, like this: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in position 604: ordinal not in range(128). How can I avoid this error? All help much

Re: error when parsing xml

2005-09-05 Thread Odd-R.
On 2005-09-05, Fredrik Lundh [EMAIL PROTECTED] wrote: Odd-R. wrote: I use xml.dom.minidom to parse some xml, but when input contains some specific caracters(æ, ø and å), I get an UnicodeEncodeError, like this: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in position 604

searching a list of dictionaries for an element in a list.

2005-08-10 Thread Odd-R.
If input is ['red','blue'], list1 is [ {'primarycolor':'red', 'secondarycolor':'burgundee'}, {'primarycolor':'red', 'secondarycolor':'wine'}, {'primarycolor':'yellow','secondarycolor':'plain'}, {'primarycolor':'blue','secondarycolor':'ocean'}]

SOAPpy and http authentication

2005-08-02 Thread Odd-R.
I use the following piece of code to contact a webservice, and read a wsdl file. from SOAPpy import WSDL from SOAPpy import URLopener url= ' http://someserver/somewebservice url1 = URLopener.URLopener(username='user',passwd='pass') server=WSDL.Proxy(url1.open(url)) This yields no errors, and

Re: regex problem

2005-07-27 Thread Odd-R.
On 2005-07-26, Duncan Booth [EMAIL PROTECTED] wrote: rx1=re.compile(r\b\d{4}(?:-\d{4})?,) rx1.findall(1234,-,4567,) ['1234,', '-,', '4567,'] Thanks all for good advice. However this last expression also matches the first four digits when the input is more than four digits. To

regex problem

2005-07-26 Thread Odd-R.
Input is a string of four digit sequences, possibly separated by a -, for instance like this 1234,-,4567, My regular expression is like this: rx1=re.compile(r\A(\b\d\d\d\d,|\b\d\d\d\d-\d\d\d\d,)*\Z) When running rx1.findall(1234,-,4567,) I only get the last match as the

find a specified dictionary in a list

2005-07-22 Thread Odd-R.
I have this list: [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] All the dictionaries of this list are of the same form, and all the oids are distinct. If I have an oid and the list, how is the simplest way of getting the dictionary that holds this oid? Thanks in

Re: find a specified dictionary in a list

2005-07-22 Thread Odd-R.
On 2005-07-22, John Machin [EMAIL PROTECTED] wrote: Odd-R. wrote: I have this list: [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] All the dictionaries of this list are of the same form, and all the oids are distinct. If I have an oid and the list, how

Dictionary to tuple

2005-06-28 Thread Odd-R.
I have a dictionary, and I want to convert it to a tuple, that is, I want each key - value pair in the dictionary to be a tuple in a tuple. If this is the dictionary {1:'one',2:'two',3:'three'}, then I want this to be the resulting tuple: ((1,'one'),(2,'two'),(3,'three')). I have been trying for