Can one get for x in y to work for non builtin classes?

2008-03-02 Thread Preben Randhol
Hi I'm making a kind of ordered dictionary class. It is not exactly a dictionary, but it uses a list and dictionary to store the data. Something like: class dbase(list): '''Database class keeping track of the order and data''' def __init__(self):

Re: Can one get for x in y to work for non builtin classes?

2008-03-02 Thread Preben Randhol
On Sun, 2 Mar 2008 15:06:17 +0100 Preben Randhol [EMAIL PROTECTED] wrote: class dbase(list): Sorry the definition of the class is: class dbase(object): it doesn't derive from the list class. Preben -- http://mail.python.org/mailman/listinfo/python-list

Re: Can one get for x in y to work for non builtin classes?

2008-03-02 Thread Preben Randhol
On Sun, 2 Mar 2008 08:09:24 -0800 (PST) [EMAIL PROTECTED] wrote: On Mar 2, 8:15 am, Giles Brown [EMAIL PROTECTED] wrote: http://docs.python.org/lib/typeiter.html Be careful on your descision to return an ordered iterator or not-- that is, whether it iterates over the dictionary or the

Re: Can one get for x in y to work for non builtin classes?

2008-03-02 Thread Preben Randhol
On Sun, 2 Mar 2008 06:15:54 -0800 (PST) Giles Brown [EMAIL PROTECTED] wrote: http://docs.python.org/lib/typeiter.html Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find number of characters in a unicode string?

2006-09-19 Thread Preben Randhol
On Mon, 18 Sep 2006 22:29:20 +0200 Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Yes and you already seem to know the answer: Decode the byte string and use `len()` on the unicode string. .decode(utf-8) did the trick. Thanks! Preben -- http://mail.python.org/mailman/listinfo/python-list

How to find number of characters in a unicode string?

2006-09-18 Thread Preben Randhol
Hi If I use len() on a string containing unicode letters I get the number of bytes the string uses. This means that len() can report size 6 when the unicode string only contains 3 characters (that one would write by hand or see on the screen). Is there a way to calculate in characters and not in

Re: Extracting values from text file

2006-06-18 Thread Preben Randhol
On Sun, 18 Jun 2006 10:54:01 +0200 Mirco Wahab [EMAIL PROTECTED] wrote: For the other issue I stumbled upon: - no DWIM-ism (do what I mean) on 'value' addition a = '1' a += '1.' print a will print 11. and not 2., as in 'dynamically typed',

Re: Extracting values from text file

2006-06-18 Thread Preben Randhol
On Sun, 18 Jun 2006 17:46:43 +0200 Mirco Wahab [EMAIL PROTECTED] wrote: Thus spoke Preben Randhol (on 2006-06-18 13:34): On Sun, 18 Jun 2006 10:54:01 +0200 Mirco Wahab [EMAIL PROTECTED] wrote: - no DWIM-ism (do what I mean) on 'value' addition But you don't add two values. you add two

Re: Extracting values from text file

2006-06-17 Thread Preben Randhol
On Sat, 17 Jun 2006 14:20:44 +0200 Mirco Wahab [EMAIL PROTECTED] wrote: Thus spoke Mirco Wahab (on 2006-06-16 21:21): I used your example just to try that in python (i have to improve my python skills), but waved the white flag after realizing that there's no easy

Extracting values from text file

2006-06-16 Thread Preben Randhol
Hi A short newbie question. I would like to extract some values from a given text file directly into python variables. Can this be done simply by either standard library or other libraries? Some pointers where to get started would be much appreciated. An example text file: --- Some text