Re: [Tutor] input and raw input
you can use an re split... import re a=raw_input(Enter the number of your class in the school:) regex = re.compile([ ,]) #sets the delimeters to a single space or comma m = regex.split(a) if you want to use any white space character than you can use [\s,] 2010/9/23 Ahmed AL-Masri ahmed...@hotmail.com Hi, any one have an idea about how we can input many number in the one time and change it to list. for example: a=input(Enter the number of your class in the school:) # the number can be enter as: 12,13,14 or 12 13 14 with a space in between. now how I can put these numbers into list like b=[12,13,14] with len( a ) =3 I tried with that but it's working only for a numbers less than 10 ex. 1,2,3 or 1 2 3 but it's not when I go for numbers higher than 10 like in example above. a=raw_input(Enter the number of your class in the school:) m=[] for I range (len( a)): if a[I]==',': pass elif a[I]==' ': pass else: m.append(a[I]) m=map(float,m) print m;print len( m ) [1,2,3] 3 looking forward to seeing your help, regards, Ahmed ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- -John Chandler ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] closing a internet explorer com object
Below is a bit of code that should work, you might want to change ieregex because right now it will close anything that has Microsoft Internet Explorer in the title bar. Have fun. import win32con import win32gui import win32process import re def getHwnds(): def callback(hwnd, hwnds): if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd): _, found_pid = win32process.GetWindowThreadProcessId(hwnd) hwnds.append(hwnd) return True hwnds = [] win32gui.EnumWindows(callback, hwnds) return hwnds ieregex = re.compile(.*Microsoft Internet Explorer.*) for hwnd in getHwnds(): name = win32gui.GetWindowText(hwnd) if ieregex.match(name): print hwnd win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) On Tue, Jun 24, 2008 at 1:33 PM, Jeff Peery [EMAIL PROTECTED] wrote: hello, I'm using internet explorer to print out html documents and I'm not sure how to close it once it is created. How do I do this? below is the simple bit of code I use to print documents. thanks! Jeff ie = win32com.client.Dispatch(InternetExplorer.Application) ie.Visible = 0 ie.Navigate(doc_name) if ie.Busy: sleep(1) # print the current IE document without prompting # the user for the printerdialog ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- -John Chandler ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to get a script to open a text file with Python?
Why not have python copy the text to the clipboard for you? You will need the win32 packages, which is hardly a turnoff since they are so useful. import win32clipboard win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(text) win32clipboard.CloseClipboard() Python puts it on the clipboard for use for you! I trump the above '5 steps' and even '1 step' with 0 steps! I hope this helps. (Remember to close the clipboard, I forgot when I was first trying to come up with this and it does not work if the clipboard remains open. Thanks goes to Bob Gailer and his 2003 post for the syntax reminder) On Tue, Jun 10, 2008 at 11:26 PM, Alan Gauld [EMAIL PROTECTED] wrote: Terry Carroll [EMAIL PROTECTED] wrote If TextPad is your default txt editor just use os.system(foo.txt) or os.startfile(foo.txt); sounds like the equivalent, but for some reason, I prefer it. Actually os.startfile was what I meant for the default case! Thanks for pointing it out. system() may work if the preference is already set but startfile is specifically intended for that scnario. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- -John Chandler ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Process that starts processes
I have been searching for a while but I can't seem to find anything that will do this, so... In my python program I am starting a process using subprocess.Popen. This is working fine, but the process I am starting starts several other processes. Is there any way (using subprocess or a different module) to control the processes the original creates (by control I mean feed them input, capture output, and kill them). I hope that is enough information (its pretty much all I have). Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor