[Tutor] Trying to write a string formatting demo

2005-04-10 Thread Dick Moores
I'm trying to write a string formatting demo, just for things like %.4f, %.3e, and %.3g. Here's what I have, but of course it doesn't work. What should the print statement be? x = raw_input("enter a float: ") if x == "": print "x will be the default 1234.56789"

Re: [Tutor] Trying to write a string formatting demo

2005-04-10 Thread Brian van den Broek
Dick Moores said unto the world upon 2005-04-10 03:38: I'm trying to write a string formatting demo, just for things like %.4f, %.3e, and %.3g. Here's what I have, but of course it doesn't work. What should the print statement be? x = raw_input("enter a float: ") if x

[Tutor] Entry widgets

2005-04-10 Thread Diana Hawksworth
Hello list,   Is it possible to change the width of an Entry widget - or not?  I am using Tkinter, GUI - and have an Entry widget that accepts a number. I just don't want it to extend the width of the column.  I have tried width =  - but get an error.   Maybe a text widget would be preferable

Re: [Tutor] Trying to write a string formatting demo

2005-04-10 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-04-10 03:58: Dick Moores said unto the world upon 2005-04-10 03:38: I'm trying to write a string formatting demo, just for things like %.4f, %.3e, and %.3g. Here's what I have, but of course it doesn't work. What should the print statement be?

Re: [Tutor] Trying to write a string formatting demo

2005-04-10 Thread Dick Moores
Brian van den Broek wrote at 01:09 4/10/2005: Hi Dick, why not replace th last line with the following 2: print_value = ('%' + s ) %x print "%f formatted with '%s' is %s" %(x, s, print_value) HTH, Brian vdB Sorry, half asleep: I should also have said that I don't think it is wise to call your user

[Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread John Ridley
Hello Brian I think the source of your problem is that the second instance of Wall_clock doesn't get deleted in the interval doctest. This is critical, because the is_instanced attribute is reset by __del__. > def interval(self, interval_name = None): > ''' > >>> # print "Testing in

[Tutor] Re: import.... (Joseph Q.)

2005-04-10 Thread Joseph Quigley
Joseph Quigley wrote on Fri, 08 Apr 2005 16:58:37 -0600: > import is handy. But my questions are: > is there a type of unimport or something to unload a module? Things which are not used are cleaned up automatically at some point. What would you like to do do that this mechanism doesn't provide? -

[Tutor] Re: problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Lee Harr
I have apparent interference between doctests embedded in the docstrings of different methods, and this interference also appears to be influenced by seemingly irrelevant things such as whether the module has a (non-doctest-containing) docstring or not. I, and what hair I've not yet torn out, woul

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
John Ridley said unto the world upon 2005-04-10 10:05: Hello Brian I think the source of your problem is that the second instance of Wall_clock doesn't get deleted in the interval doctest. This is critical, because the is_instanced attribute is reset by __del__. def interval(self, interval_name =

Re: [Tutor] Entry widgets

2005-04-10 Thread Michael Lange
On Sun, 10 Apr 2005 18:07:48 +1000 "Diana Hawksworth" <[EMAIL PROTECTED]> wrote: > Hello list, > > Is it possible to change the width of an Entry widget - or not? I am using > Tkinter, GUI - and have an Entry widget that accepts a number. I just don't > want it to extend the width of the colum

Re: [Tutor] Re: problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
Lee Harr said unto the world upon 2005-04-10 10:21: I have apparent interference between doctests embedded in the docstrings of different methods, and this interference also appears to be influenced by seemingly irrelevant things such as whether the module has a (non-doctest-containing) docstring o

Re: [Tutor] Re: import.... (Joseph Q.)

2005-04-10 Thread Kent Johnson
Joseph Quigley wrote: > Well, I'm importing a custom module, and I can't loop back to the module I imported (the modules are different modes of the program. Someone suggested classes, but I have no idea how to use them. I'm not sure I understand you, but it sounds like you have two versions of a

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Kent Johnson
As John Ridley suggests, you have to balance creation and deletion of Wall_clock instances. But unfortunately del wc does not necessarily call Wall_clock.__del__() immediately. See below for more... Brian van den Broek wrote: def check_point(self, check_point_name = None): '''Creates

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-10 15:11: As John Ridley suggests, you have to balance creation and deletion of Wall_clock instances. But unfortunately del wc does not necessarily call Wall_clock.__del__() immediately. Hi Kent and all, OK, the delay between the statement del(wc) an

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread John Ridley
--- Brian van den Broek <[EMAIL PROTECTED]> wrote: > But: it still leaves me wondering why removing either a) the one-line > no-doctest-containing docstring of the Wall_clock class or b) the > unreferenced Wall_clock.stop_interval method made my original test > code pass without needing to effec

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
John Ridley said unto the world upon 2005-04-10 19:19: --- Brian van den Broek <[EMAIL PROTECTED]> wrote: But: it still leaves me wondering why removing either a) the one-line no-doctest-containing docstring of the Wall_clock class or b) the unreferenced Wall_clock.stop_interval method made my o

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Rich Krauter
Brian van den Broek wrote: [text and code snipped] FWIW, I ran your code using python 2.3.4 on linux with the following modifications, and it worked fine (no failing tests out of 9): 1- added 'from sets import Set as set' since set() isn't built in in 2.3 2- changed True back to False in the foll

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Kent Johnson
Brian van den Broek wrote: I've not fully grokked the doctest code (which I delved into after Lee Harr suggested I do so), but I would have thought that each doctest had its own copy of the Wall_clock class from copying globals. But here, I surely have more work to do myself :-) doctest makes a sha

[Tutor] Looking for a number adding script

2005-04-10 Thread Kenny Li
Hi all, A little while ago, when I tried to pick up Python, I ran into an article that has a script to add up all numbers in a text file (email message, for example). I want to use that script now, but I could not find (recalled) the URL to the article. If you have a point, please let me know. App

Re: [Tutor] Looking for a number adding script

2005-04-10 Thread jfouhy
Quoting Kenny Li <[EMAIL PROTECTED]>: > A little while ago, when I tried to pick up Python, I ran into an > article that has a script to add up all numbers in a text file (email > message, for example). I want to use that script now, but I could not > find (recalled) the URL to the article. If you

[Tutor] Re: import.... (Joseph Q.)

2005-04-10 Thread Andrei
Joseph Quigley gmail.com> writes: > Well, I'm importing a custom module, and I can't loop back to the module I > imported (the modules are different modes of the program. Someone suggested > classes, but I have no idea how to use them. So you have two modules which implement the same function

Re: [Tutor] Entry widgets

2005-04-10 Thread Diana Hawksworth
Thanks Michael. Your suggestions did the trick! I did mean to include my code - but obviously did not do that. Appreciate your help. Diana - Original Message - From: "Michael Lange" <[EMAIL PROTECTED]> To: Sent: Monday, April 11, 2005 1:49 AM Subject: Re: [Tutor] Entry widgets > On Su