convert char to byte representation

2005-10-10 Thread Philipp H. Mohr
Hello, I am trying to xor the byte representation of every char in a string with its predecessor. But I don't know how to convert a char into its byte representation. This is to calculate the nmea checksum for gps data. e.g. everything between $ and * needs to be xor: $GPGSV,3,1,10,06,79,

Store multiple dictionaries in a file

2005-06-30 Thread Philipp H. Mohr
Hello, I would like to store multiple dictionaries in a file, if possible one per line. My code currently produces a new dictionary every iteration and passes it on to another peace of code. In order to be able to re-run some experiments at a later date I would like to store every dictionary in th

Re: Store multiple dictionaries in a file

2005-06-30 Thread Philipp H. Mohr
Thank you for you answer. > > I would like to store multiple dictionaries in a file, if possible one per > > line. > > Why "one per line" ? I agree with you that it sounds like nasty code :-) but there is a good reason for doing it this way - I think. My code collects data (attributes) of its cu

Re: Store multiple dictionaries in a file

2005-06-30 Thread Philipp H. Mohr
Hello, this is the solution I went for, as I am indeed not concernt about security and the implementation is straight forward. Thank you, Phil > If you're not worried about security, you could write the repr() of each > dict to the file and get the values back by using the eval() function. > r

passing arguments to a function - do I need type ?

2005-07-10 Thread Philipp H. Mohr
Hello, I got a newbie question, I have written the following distance function: def distance(self,element1, element2): dist = 0 for n in range(len(element1)): dist = dist + pow((element1[n] - element2[n]),2) print 'dist' + dist return sqrt(dist) and i

Re: passing arguments to a function - do I need type ?

2005-07-10 Thread Philipp H. Mohr
Hello, thank you very much for all your help. I have solved the problem - you guys where right, the problem was some where else. I have another class which got an accessor: def getCenter(self): global center return center and I called it by saying n.getCenter, but this returns:

Abstract methods in python - is this a good way ?)

2005-08-07 Thread Philipp H. Mohr
Hello, I would like to use abstract methods in python to force some of the classes to implement common methods. I found this web page and wonder if it is a good way of implementing them: http://www.lychnis.net/blosxom/programming/python-abstract-methods-3.lychnis Also could some one please tel