Re: [Tutor] Need Some Help

2007-08-27 Thread Michael
Hi I have just taught myself some Python and among my resources were... http://www.ibiblio.org/obp/thinkCSpy/ - I worked my way through over half of this online and downloadable manual http://www.livewires.org.uk/python/index.html - This course is good, I am currently working through this

[Tutor] validation

2007-08-27 Thread Michael
Hi I am fairly new to Python and I wish to validate input. Such as wanting to check and make sure that an integer is entered and the program not crashing when a naughty user enters a character instead. I have been trying to use the Type() function but I cannot work out how to check the return

Re: [Tutor] validation

2007-08-27 Thread Shantanoo Mahajan
On 27-Aug-07, at 2:20 PM, Michael wrote: > Hi > > I am fairly new to Python and I wish to validate input. Such as > wanting > to check and make sure that an integer is entered and the program not > crashing when a naughty user enters a character instead. I have been > trying to use the Type() f

Re: [Tutor] validation

2007-08-27 Thread John Fouhy
On 27/08/07, Michael <[EMAIL PROTECTED]> wrote: > I am fairly new to Python and I wish to validate input. Such as wanting > to check and make sure that an integer is entered and the program not > crashing when a naughty user enters a character instead. I have been > trying to use the Type() functio

Re: [Tutor] validation

2007-08-27 Thread Alan Gauld
"Michael" <[EMAIL PROTECTED]> wrote > to check and make sure that an integer is entered and the program > not > crashing when a naughty user enters a character instead. John F has already pointed you to the use of try/except for this, however... > trying to use the Type() function but I cannot

Re: [Tutor] How to put an event into the Tcl/Tk event queue?

2007-08-27 Thread Dan Knierim
Hello Mr. Gauld, Your second guess about the scenario is right: I want to automate tests of Tcl/Tk GUIs. I know about the GUI test automation tools like WATSUP, PyWinAuto, winGuiAuto etc., and will use one if necessary. But test automation is usually easier at the lowest possible level for the t

Re: [Tutor] validation

2007-08-27 Thread Kent Johnson
Alan Gauld wrote: > "Michael" <[EMAIL PROTECTED]> wrote >> trying to use the Type() function but I cannot work out how to check >> the >> return value? Caomparing it to 'int' or 'str' isn't working, > > The easiest way is to compare to another type: > > x = 42 > if type(x) == type(int()): > > o

Re: [Tutor] validation

2007-08-27 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> if type(x) == type(int()): >> > For the built-in types, since Python 2.2 the familiar name (int, > str, > float, list, dict, set) *is* the type and you can compare to that > directly, e.g.: > > In [13]: type(3)==int > Out[13]: True I knew I should be

Re: [Tutor] How to put an event into the Tcl/Tk event queue?

2007-08-27 Thread Alan Gauld
"Dan Knierim" <[EMAIL PROTECTED]> wrote in > The Tcl/Tk functions I mentioned (Tcl_QueueEvent etc.) are > listed in my copy of the Tcl/Tk Man pages (downloadable > from www.tcl.tk/man). > I believe they are C or C++ functions. That's what I suspected, the names look like the C functions. > Is th

[Tutor] Detecting sequences in lists

2007-08-27 Thread Tino Dai
Hi Everybody, Thank you so much for the information on sets. I think that that has certain uses, but in my case I can't find a way. I have been thinking about sequences in a list. Let me give you an example: tset = [ 1,2,4,0,0,1,2,4,4] What I want to do is detect the 1,2,4 sequence and pe

Re: [Tutor] Detecting sequences in lists

2007-08-27 Thread Lutz Horn
Hi, DIY is easy. On Mon, 27 Aug 2007 09:20:53 -0400, "Tino Dai" <[EMAIL PROTECTED]> said: > What I want to do is detect the 1,2,4 sequence and perhaps how many. >>> tset = [ 1,2,4,0,0,1,2,4,4] >>> s = [1, 2, 4] >>> c = 0 >>> for i in range(len(tset) - len(s)): ... if tset[i:i+len(s)] == s: .

Re: [Tutor] Detecting sequences in lists

2007-08-27 Thread Kent Johnson
Tino Dai wrote: > Hi Everybody, > >Thank you so much for the information on sets. I think that that > has certain uses, but in my case I can't find a way. I have been > thinking about sequences in a list. Let me give you an example: > > tset = [ 1,2,4,0,0,1,2,4,4] > > What I want to do

[Tutor] Equivalent of && in Python?

2007-08-27 Thread wormwood_3
I have a script that reads some local system information, performs some calculations, and then launches some terminal windows: # Spawn the 4 terminals, with needed positions and sizes, then exit commands.getoutput("%s --geometry=%dx%d+%d+%d --working-directory=%s" % \ (terminal, t1width, t1he

Re: [Tutor] Equivalent of && in Python?

2007-08-27 Thread Eric Brunson
wormwood_3 wrote: > I have a script that reads some local system information, performs some > calculations, and then launches some terminal windows: > > # Spawn the 4 terminals, with needed positions and sizes, then exit > commands.getoutput("%s --geometry=%dx%d+%d+%d --working-directory=%s" % \ >

[Tutor] user in put

2007-08-27 Thread Latasha Marks
Need help get a user to in put his or her favortie food the the program should the n print oue the name of the new food by joining the original food names together code: favortie_food= raw_input("What is your favortie food?") What is your favortie food? hot dog >>> print favortie_food

Re: [Tutor] validation

2007-08-27 Thread Terry Carroll
On Mon, 27 Aug 2007, Kent Johnson wrote: > For the built-in types, since Python 2.2 the familiar name (int, str, > float, list, dict, set) *is* the type and you can compare to that > directly, e.g.: > > In [13]: type(3)==int > Out[13]: True > In [14]: type([]) == list > Out[14]: True That is s

Re: [Tutor] validation

2007-08-27 Thread Kent Johnson
Terry Carroll wrote: > I ended up writing a short isListOrTuple function that went something > like this: > > def isListOrTuple(thing): > result = False > if isinstance(thing, list): result = True > if isinstance(thing, tuple): result = True > return result isinstance can take a tuple o

[Tutor] Question about installing 2.51

2007-08-27 Thread Dick Moores
XP, Python 2.5 I just downloaded python-2.5.1.msi from python.org. During the installation process (which I aborted), I was told, "This Update will replace your existing Python25 installation". What exactly does this mean? What will happen, for example, to all my scripts that are in E:\Python2

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Kent Johnson
Dick Moores wrote: > XP, Python 2.5 > > I just downloaded python-2.5.1.msi from python.org. During the > installation process (which I aborted), I was told, "This Update will > replace your existing Python25 installation". > > What exactly does this mean? What will happen, for example, to all m

Re: [Tutor] user in put

2007-08-27 Thread Dave Kuhlman
On Mon, Aug 27, 2007 at 11:02:59AM -0700, Latasha Marks wrote: > Need help get a user to in put his or her favortie food the the > program should the n print oue the name of the new food by > joining the original food names together If what you want is to enable your user to enter several foods (

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > installation process (which I aborted), I was told, "This Update > will > replace your existing Python25 installation". > > What exactly does this mean? What will happen, for example, to all > my > scripts that are in E:\Python25\dev? Or to the packages

Re: [Tutor] validation

2007-08-27 Thread Terry Carroll
On Mon, 27 Aug 2007, Kent Johnson wrote: > isinstance can take a tuple of types as its second argument > > Note that >isinstance(thing, (list, tuple)) > > and >type(thing) in [list, tuple] > > are not equivalent. The first will be true for objects whose type is a > subclass of list

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Dick Moores
At 02:00 PM 8/27/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > installation process (which I aborted), I was told, "This Update > > will > > replace your existing Python25 installation". > > > > What exactly does this mean? What will happen, for example, to all > > my > >

[Tutor] tagging pieces of information

2007-08-27 Thread Che M
Hi, I am curious about ways in Python to approach the idea of "tagging" pieces of information much in the way that one can tag favorite websites like on the site Del.icio.us. I'm not sure if tagging is the best term for this (due to confusion with HTML tags), but the idea would be a way to ass

Re: [Tutor] tagging pieces of information

2007-08-27 Thread John Fouhy
On 28/08/07, Che M <[EMAIL PROTECTED]> wrote: > Hi, I am curious about ways in Python to approach the idea of "tagging" > pieces of information much in the way that one can tag favorite websites > like on the site Del.icio.us. I'm not sure if tagging is the best term for > this (due to confusion w

Re: [Tutor] tagging pieces of information

2007-08-27 Thread Ian Witham
You may be able to use a dictionary to store your data chunks. eg: >>> tagged_items = {('spam, swordfights'): 'ITEM A', ... ('swordfights', 'custard'): 'ITEM B'} >>> [tagged_items[tags] for tags in tagged_items if 'spam' in tags] ['ITEM A'] >>> [tagged_items[tags] for tags in tagged_items if '

Re: [Tutor] tagging pieces of information

2007-08-27 Thread Eric Abrahamsen
On Aug 28, 2007, at 11:07 AM, Che M wrote: > I don't know if there are any preexisting Python structures which > would help > with this or if it has to be done by scratch, or if it is easy or > difficult. > I also don't know what are good ideas for ways to save the tags, > whether > in a t