Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
rantingrick writes: > On Sep 6, 5:00 pm, Bart Kastermans wrote: >> rantingrick writes: >> > Hmm, i can replace all that code with this... >> >> Because I stupidly forgot to repeat the original problem I had, and my >> code doesn't show it (and doesn

Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
rantingrick writes: > Hmm, i can replace all that code with this... Because I stupidly forgot to repeat the original problem I had, and my code doesn't show it (and doesn't show the correct use of the function I wrote). The code shows that I now know how to compute the number of lines and item

Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
I build on the suggestion by rantingrick, but took it in a bit different direction. I now have working code that performs reasonable. The reason for the class lines (as opposed to just a function) is b/c font.measure appears not that fast. So I want to remember between different calls to lines.

Re: Tkinter label height to fit content

2011-09-04 Thread Bart Kastermans
rantingrick writes: > On Sep 3, 5:15 pm, Bart Kastermans wrote: > >> Any suggestions? > > Yeah, have you considered using the "linespace()" method of tk.Font > objects to calculate the height? Although i must say it "feels" as if > your doing so

Tkinter label height to fit content

2011-09-03 Thread Bart Kastermans
I have a label into which I am going to put content of different sizes. I would like to know how high I need to make the label so that I can size the window so it can stay the same for the different content sizes. I have a strategy, but it seems more complicated then it should be. I want to set a

Re: List comprehension timing difference.

2011-09-02 Thread Bart Kastermans
t...@thsu.org writes: > On Sep 2, 9:54 am, Bart Kastermans wrote: >> if d(a,b) == 1 and a < b: > > It will probably be faster if you reverse the evaluation order of that > expression. > > if a > That way the d() function is called less than half the time. Of cours

Re: List comprehension timing difference.

2011-09-02 Thread Bart Kastermans
MRAB writes: > On 02/09/2011 01:35, Bart Kastermans wrote: >> graph = [[a,b] for a in data for b in data if d(a,b) ==1 and a< b] >> graph2 = [] >> for i in range (0, len(data)): >> for j in range(0,len(data)): >> if d(data[i],data[j]) ==

List comprehension timing difference.

2011-09-01 Thread Bart Kastermans
In the following code I create the graph with vertices sgb-words.txt (the file of 5 letter words from the stanford graphbase), and an edge if two words differ by one letter. The two methods I wrote seem to me to likely perform the same computations, the list comprehension is faster though (281

First Tkinter script: requesting comments

2010-05-21 Thread Bart Kastermans
that in the future we can # act on it). # # Bart Kastermans, www.bartk.nl """ Design of the window +-

Negative regular expressions (searching for "i" not inside command)

2008-08-28 Thread Bart Kastermans
I have a file in which I am searching for the letter "i" (actually a bit more general than that, arbitrary regular expressions could occur) as long as it does not occur inside an expression that matches \\.+?\b (something started by a backslash and including the word that follows). More concrete e

Re: Changing self: if self is a tree how to set to a different self

2008-07-13 Thread Bart Kastermans
Paul McGuire <[EMAIL PROTECTED]> writes: > On Jul 12, 6:18 am, Bart Kastermans <[EMAIL PROTECTED] > macbook.local> wrote: >> This uses the function: >> >> def NoneOr (tree, mem_function, *arguments): >>     """ if tree is not None then

Re: Correct use of try,except and raise?

2008-07-13 Thread Bart Kastermans
Roy Smith <[EMAIL PROTECTED]> writes: > ssecorp <[EMAIL PROTECTED]> wrote: > >> i dont get what you mean, if i dont do anything python will raise an >> indexerror so it is an indexerror. > > You wrote: > >> > >     def pop(self): >> > >         try: >> > >             return self.queue.pop(0) >> >

Re: Changing self: if self is a tree how to set to a different self

2008-07-12 Thread Bart Kastermans
Terry Reedy <[EMAIL PROTECTED]> writes: > Bart Kastermans wrote: >> I am playing with some trees. In one of the procedures I wrote >> for this I am trying to change self to a different tree. A tree >> here has four members (val/type/left/right). I found that self =

Changing self: if self is a tree how to set to a different self

2008-07-10 Thread Bart Kastermans
I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS does not work; I have to write self.val = SS.val and the same for the other members (as shown below).

Strings are better than lists for the tree to string operation.

2008-06-30 Thread Bart Kastermans
> |    def __str__ (self): > > string appending is an O(n**2) operations.  The usual idiom, applied here, > would be slist = ['('], slist.append(str(self.value)), return > ''.join(slist).  In other words, collect list of pieces and join at end. I did some timing of operations involved. Doing

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-21 Thread Bart Kastermans
On Jun 17, 1:01 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 16 Jun 2008 07:34:06 -0300, Bart Kastermans <[EMAIL PROTECTED]> > escribió: > > > Summary: can't verify big O claim, how to properly time this? > > > This is in

String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Bart Kastermans
Summary: can't verify big O claim, how to properly time this? On Jun 15, 2:34 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Bart Kastermans" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > |I wrote a binary search tree in pytho

Explaining Implementing a Binary Search Tree.

2008-06-15 Thread Bart Kastermans
I wrote a binary search tree in python, explaining as I was doing it how and why I did it. I am very interested in receiving comments on the code, process, and anything else that will improve my coding or writing. I wrote this all up in my blog at: http://kasterma.wordpress.com/2008/06/15/implem

Re: Gmail imap search does not get all messages.

2008-02-02 Thread Bart Kastermans
Quick update on the below: the issue has disappeared by itself. I did not get to working on this much since sending my last message. Now that I am looking at this the issue has disappeared. On Jan 29, 8:23 pm, Bart Kastermans <[EMAIL PROTECTED]> wrote: > I am trying to use imaplib w

Re: Fw: Undeliverable Message

2008-01-30 Thread Bart Kastermans
On Jan 25, 5:05 am, [EMAIL PROTECTED] wrote: > Hallo pyPeople, > > I wrote a little snippet of code that takes a list representing some > 'digits', and according to a list of symbols, increments the digits through > the symbol list. > > so for example, > > digits=["a","a","a"] > symbols=["a","b","

Gmail imap search does not get all messages.

2008-01-29 Thread Bart Kastermans
I am trying to use imaplib with gmail. I am finding however that with the gmail server imaplib.search does not give the correct answer. See the below traces (k is a server a my department, i is gmail). k has 6 messages in the INBOX i has 3 messages in the INBOX However i.search(None, "ALL") only

Re: Convert list to file object without creating an actual file.

2008-01-25 Thread Bart Kastermans
The suggestion to use StringIO to make a string have the same interface as a file works perfect in my situation. Here is now the working result (just in case it is useful to anyone) part of this is still a definite hack and suggestions for improvement are certainly appreciated. Want: have an easi

Convert list to file object without creating an actual file.

2008-01-24 Thread Bart Kastermans
I have written a little program that takes as input a text file, converts it to a list with appropriate html coding (making it into a nice table). Finally I want to upload this list as a textfile using ftp. If homeworkhtml contains the list of lines; e.g. homeworkhtml = ["", "", "", "test", "" ...