Re: [Tutor] Sorting more than one list
> I need to sort 4 lists but I need that they make the "sort together". > I'll sort just one but when I change the position of the items of the > 1st list I have to change the positions of the other 3 lists. Can I do > this just using the sort() method of the list object? > If I can't, someone know a site that have one sort method in python that > its easily to implement and fast? Since the data are obviously related (since you need to keep them linked), I'd be inclined to merge the lists into a list of tuples merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4] Then you can sort 'merged' and it should just work The default sort will order the tuples by the first member... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sorting more than one list
On Apr 1, 2005, at 09:59, Alan Gauld wrote: Since the data are obviously related (since you need to keep them linked), I'd be inclined to merge the lists into a list of tuples merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4] Then you can sort 'merged' and it should just work The default sort will order the tuples by the first member... Alan G. What's the advantage of this compared to the "zip" method (which yields the same result AFAICT)? -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 "Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What is the best book to start?
> I am starting to studying Python. I have some previous > experience with C (beginner level). Probably the standard tutorial on the web site is the best place for you to start. > "Learning Python" by Lutz & Ascher, And this is very good supporting material. > "Python How to Program" by Deitel and others. And this is particularly good as an intro into the wider areas such as PyGame, XML/HTML GUIs and Network programming. The early chapters are done better IMHO by Lutz, aand the official tutor. Your next purchase should be either or both of: Python in a Nutshell - a great 'pocket' reference and Python Programming on Win32 - but only if you are using Windows of course! You have more than enough beginner material already. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What is the best book to start?
> I really think alan gauld books, learning how to program is one of the > best esp if you are new. Thanks for the kind words! :-) However if the OP has some C - my book will likely be too basic, it starts from ground zero, but anyone who has used C will find the pace too slow I suspect. OTOH The Advanced Topics section of my web tutorial might be worth a visit when newer concepts like OOP and Functuional programming get reached. But thanks again for the plug! :-) Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython / Tkinter Grid
> I know a wxPython grid is totally different to a Tkinter grid, but is > there a Tkinter equivalent of a wxPython grid? I'm finding wxPython to > be fiddly and restrictive... Then Tkinter will be more so. Tk is a fairly basic toolkit, fine for wrapping a command line app in a glossy front end but not for sophisticated GUI work. There is no grid component in Tk out of the box, but some add on toolkits supply one. Try searching on the Vaults of Parnassus or on the ActiveState site if you are determined to try Tkinter... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] updating Oracle tables via python
Hi all, 1) this are the *correct* quotation marks: strUpdate = " UPDATE table SET firstname = 'JOSEPH' WHERE lastname = 'SMITH' " because SQL uses single quotation marks for character strings in column values. Double quotation marks are used to quote a column name when the column name is defined in mixed case letters (if the column name is all in small or capital letters there is no need for quoting the column name) 2) I guess that the problem is that there's no finishing semicolon (;) for the statement, because the native Oracle SQL-command interpreter 'sqlplus' requires a semicolon at the end of each SQL statement 3) Don't call the table which You want to update 'table' 'table' is a reserved word in SQL and for the update-statement You have to specify the name of the table (i.e.: namelist ) - and make sure that You have created the table via a 'CREATE TABLE ...' statement before and inserted some values in it That's my five cent... best wishes, Ralf Liam Clarke <[EMAIL PROTECTED]> schrieb am 30.03.05 02:14:05: > > >From what little SQL I know, > > try using your quotation marks differently, see if it helps. > > strUpdate = 'UPDATE table SET firstname = "JOSEPH" WHERE lastname = "SMITH" ' > > Good luck, > > Liam Clarke -snip > > script will print all of the print commands up to the > > cursor.execute(strUpdate) command, but not those after it. Therefore, I > > think that the cursor.execute(strUpdate) is the source of the problem. > > Also, when I manually query the database, the records within the table have > > not been changed. > > > > Thanks, > > > > Tom -snip > > strUpdate = " UPDATE table SET firstname = 'JOSEPH' WHERE lastname = > > 'SMITH' " ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I am puzzled - help needed
> from time import * > > n = time() > s = str(n) > numb = s[-2:] # last two characters of the string > numb = int(numb) # convert back to a number > guess = (raw_input('Enter a number: ')) You need to convert the string returned by raw_input() into a number guess = int(raw_input('Enter a number: ')) otherwise you are comparing a string with anumber. > if guess == numb: > print ("Bravo, you have just won the right to play again!") > > elif guess < numb: > print "You are just a bit too low, try again" > > else: > print "You are just a bit too high, try again" > > print "The End" > > If i write the following line: > "n = time.time() > > I get the following error message: > AttributeError: 'builtin_function_or_method' object has no attribute 'time' Thats because you used from time import * So when you type time.time Python sees the first 'time' as being the time modules time() function. When you type time.tuime it tries to access a time attribute of the time function. That doesn't exist which is what the error says... Use either import time t = time.time() OR from time import time t= time() Its considered bad practice to use from time import * because its easy to get collisions between names in the time module and other names in your program. > I feel like an idiot asking what is probably very basics questions but my > desire to learn is quite high right now and I don't want to lose it, thanks > again Ask away, thats what the list is for. None of your questions have been in any way stupid. And we do try to answer stupid questions too! :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] function loading a file's lines to a list
I'm working on this coding assignment I had for a c++ class. For fun, I decided to implement it in Python, and I'm done. Still, I found a behaviour I can't explain: The function loadfromfile def loadfromfile(lines, fname): try: finput = file(fname, 'r') lines = [] for line in finput: line = line[:-1] lines.append(line) finput.close() return lines except: print "Couldn't load from file %s" % (fname) takes a file (referenced by fname) and appends each line of text in it to a list called lines (a global var, see full code below). Problem is, as soon as I leave the function, lines is empty. Even when I'm returning it, non-empty. I tried putting a print statement just before "return lines" and it shows the complete list (according to what was in the file, obviously). But after that, the contents are emptied. Modifying that function to def loadfromfile(fname): try: finput = file(fname, 'r') global lines lines = [] for line in finput: line = line[:-1] lines.append(line) finput.close() #return lines except: print "Couldn't load from file %s" % (fname) works (with or without the return lines statements, that's why I commented it), but I don't understand why. I know lists are modified in- place, so I'd imagine it would work in the first case too. --- Full code below: #!/usr/bin/env python # pysimpleditor: a concept - text editor # Global vars: lines = [] # Holds the lines of text in memory. # Functions: # insertline inserts text into lines _before_ the index linenumber. def insertline(lines, linenumber): try: line = int(linenumber) except: print "not a valid line number" text = raw_input("Input text: ") lines.insert(line, text) #deleteline deletes the line of text at lines[linenumber] def deleteline(lines, linenumber): try: line = int(linenumber) except: print "not a valid line number" lines.pop(line) # Print the lines to the screen def printlines(lines): for line in lines: print line # Saves list lines to file fname. def savetofile(lines, fname): try: foutput = file(fname, 'w') for line in lines: line = line + '\n' foutput.write(line) foutput.close() except: print "Couldn't open file %s for saving" % (fname) # Loads text from fname into list lines. def loadfromfile(fname): try: finput = file(fname, 'r') global lines lines = [] for line in finput: line = line[:-1] lines.append(line) finput.close() except: print "Couldn't load from file %s" % (fname) def printhelp(): print """ pysimpleeditor: A simple text editor. Use: In: inserts a line of text before line n. En: deletes line n. V: prints all lines on the screen. S: saves the lines of text to a file. C: loads text from a file. H: this message. F: exit the program. """ #The program: while True: choice = raw_input("Please enter a command (h for help): ") choice = choice.upper() # Why bother the user with caps or uncaps? if choice[0] == 'I':# Line addition insertline(lines, choice[1:]) elif choice[0] == 'E': # Line deletion deleteline(lines, choice[1:]) elif choice[0] == 'V': # Text visualization for line in lines: print line elif choice[0] == 'S': # Save text to file fname = raw_input("Enter a filename to save: ") savetofile(lines, fname) elif choice[0] == 'C': # Load text from file, _replaces_ list! fname = raw_input("Enter a filename to load: ") loadfromfile(fname) elif choice[0] == 'H': printhelp() elif choice[0] == 'F': # Exits the program break else: print "%s is not a valid command. Press h for help" % (choice[0]) -- Adriano Varoli Piazza The Inside Out: http://moranar.com.ar MSN: [EMAIL PROTECTED] ICQ: 4410132 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] function loading a file's lines to a list
Il giorno ven, 01-04-2005 alle 12:01 +0200, Adriano Varoli Piazza ha scritto: [... Massive lines of code ...] It's possibly of interest that I'm running this with python 2.4.1 compiled from source on Fedora Core 3. Thanks for the patience -- Adriano Varoli Piazza The Inside Out: http://moranar.com.ar MSN: [EMAIL PROTECTED] ICQ: 4410132 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] function loading a file's lines to a list
Hi! on Fri, 01 Apr 2005 12:01:02 +0200 Adriano Varoli Piazza <[EMAIL PROTECTED]> wrote : - Adriano Varoli Piazza > Adriano Varoli Piazza > def loadfromfile(fname): Adriano Varoli Piazza > try: Adriano Varoli Piazza > finput = file(fname, 'r') Adriano Varoli Piazza > global lines global say, that lines is "global" defined. Otherwise as in your first version the lines-List is defined local in the loadfromfile()-function. (You can return the local list and assign it, where you call the loadfromfile()- function. ) Adriano Varoli Piazza > lines = [] Adriano Varoli Piazza > for line in finput: Adriano Varoli Piazza > line = line[:-1] Adriano Varoli Piazza > lines.append(line) Adriano Varoli Piazza > finput.close() Adriano Varoli Piazza > #return lines As you do not use the returned value of loadfromfile(), it's useless here. Adriano Varoli Piazza > except: Adriano Varoli Piazza > print "Couldn't load from file %s" % (fname) Adriano Varoli Piazza > Adriano Varoli Piazza > works (with or without the return lines statements, that's why I Adriano Varoli Piazza > commented it), but I don't understand why. I know lists are modified in- Adriano Varoli Piazza > place, so I'd imagine it would work in the first case too. Adriano Varoli Piazza > --- end -- HTH Ewald ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] function loading a file's lines to a list
Il giorno ven, 01-04-2005 alle 12:46 +0200, Ewald Ertl ha scritto: > Hi! > > on Fri, 01 Apr 2005 12:01:02 +0200 Adriano Varoli Piazza <[EMAIL PROTECTED]> > wrote : > - > > Adriano Varoli Piazza > > Adriano Varoli Piazza > def loadfromfile(fname): > Adriano Varoli Piazza > try: > Adriano Varoli Piazza > finput = file(fname, 'r') > Adriano Varoli Piazza > global lines > > global say, that lines is "global" defined. Otherwise as in your first > version the lines-List is defined local in the loadfromfile()-function. > (You can return the local list and assign it, where you call the > loadfromfile()- > function. ) I understand now. I got confused with "lists elements are changed in place"... Thanks -- Adriano Varoli Piazza The Inside Out: http://moranar.com.ar MSN: [EMAIL PROTECTED] ICQ: 4410132 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython / Tkinter Grid
On Fri, 1 Apr 2005 09:11:20 +0100 "Alan Gauld" <[EMAIL PROTECTED]> wrote: > > I know a wxPython grid is totally different to a Tkinter grid, but > is > > there a Tkinter equivalent of a wxPython grid? I'm finding wxPython > to > > be fiddly and restrictive... > > Then Tkinter will be more so. Tk is a fairly basic toolkit, fine for > wrapping a command line app in a glossy front end but not for > sophisticated GUI work. > > There is no grid component in Tk out of the box, but some add on > toolkits > supply one. Try searching on the Vaults of Parnassus or on the > ActiveState site if you are determined to try Tkinter... > > Alan G. > Or look here: http://tkinter.unpythonic.net/wiki/Widgets There is a number of links to table widget implementations in Tkinter o nthe wiki page. I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sorting more than one list
Max Noel wrote: On Apr 1, 2005, at 09:59, Alan Gauld wrote: Since the data are obviously related (since you need to keep them linked), I'd be inclined to merge the lists into a list of tuples merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4] Then you can sort 'merged' and it should just work The default sort will order the tuples by the first member... Alan G. What's the advantage of this compared to the "zip" method (which yields the same result AFAICT)? Yikes! Alan must have been up too late. They are not the same at all. Alan's code creates a list containing *every combination* of one element from each source list: >>> a=[1,2,3] >>> b=[4,5,6] >>> c=[7,8,9] >>> [ (aa,bb,cc) for aa in a for bb in b for cc in c ] [(1, 4, 7), (1, 4, 8), (1, 4, 9), (1, 5, 7), (1, 5, 8), (1, 5, 9), (1, 6, 7), (1, 6, 8), (1, 6, 9), (2, 4, 7), (2, 4, 8), (2, 4, 9), (2, 5, 7), (2, 5, 8), (2, 5, 9), (2, 6, 7), (2, 6, 8), (2, 6, 9), (3, 4, 7), (3, 4, 8), (3, 4, 9), (3, 5, 7), (3, 5, 8), (3, 5, 9), (3, 6, 7), (3, 6, 8), (3, 6, 9)] This is very different from zip(a,b,c) which makes a list of *corresponding* items from each list: >>> zip(a,b,c) [(1, 4, 7), (2, 5, 8), (3, 6, 9)] Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cryptography Toolkit
It works if you make a new XOR object for the decryption: from Crypto.Cipher import XOR obj_xor = XOR.new("string") str_encrypt = "encrypt this string" print str_encrypt xored = obj_xor.encrypt(str_encrypt) print xored obj_xor = XOR.new("string") print obj_xor.decrypt(xored) Kent Mark Thomas wrote: On Thu, 31 Mar 2005 09:14:03 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: If you post your code and the complete error message including the stack trace we may be able to help. Kent Thanks Ken I'm getting closer to making this work using the XOR cipher. Here's what I'm doing. from Crypto.Cipher import XOR obj_xor = XOR.new("string") str_encrypt = "encrypt this string" xored = obj_xor.encrypt(str_encrypt) xored '\x16\x1a\x11\x1b\x17\x17\x07T\x06\x01\x07\x14S\x07\x06\x1b\x07\t\x14' obj_xor.decrypt(xored) "bhxupds&oo`g'uou`z`" <== *confused by this output* Close but no cigar!! *grin* ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What is the best book to start?
Subject: Re: [Tutor] What is the best book to start? From: "Alan Gauld" <[EMAIL PROTECTED]> Date: Fri, 1 Apr 2005 09:05:16 +0100 To: "Hoffmann" <[EMAIL PROTECTED]>, To: "Hoffmann" <[EMAIL PROTECTED]>, I am starting to studying Python. I have some previous experience with C (beginner level). Probably the standard tutorial on the web site is the best place for you to start. "Learning Python" by Lutz & Ascher, And this is very good supporting material. "Python How to Program" by Deitel and others. And this is particularly good as an intro into the wider areas such as PyGame, XML/HTML GUIs and Network programming. The early chapters are done better IMHO by Lutz, aand the official tutor. Your next purchase should be either or both of: Python in a Nutshell - a great 'pocket' reference and Python Programming on Win32 - but only if you are using Windows of course! You have more than enough beginner material already. Alan G. I'd also try to fit in Dive Into Python [http://diveintopython.org/]. This book really got me hooked on Python. It assumes you know some programming. Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] A Newbie Printing Question
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > > Quoting "Jacob S." <[EMAIL PROTECTED]>: > > > Cool! Does anybody know of... I guess a rather *thorough* > tutorial of > > win32? for the very reason that I don't know that this > existed, and there may > > be other things I can use that I'm missing... > > I don't know of anything online ... It seems a very > poorly-documented corner of > Python. Since the pywin32 stuff just wraps standard Win32 libraries for the most part, the resources at MSDN (http://msdn.microsoft.com) are quite helpful. While it is not Python-specific, it would probably be redundant to extensively document the pywin32 stuff with MSDN available. > Oreilly have a book which may be of help to you if you do a > lot of programming > on Windows: http://www.oreilly.com/catalog/pythonwin32/ I agree. It is an older book, but I found it helpful. I think I got it used for $6 or $8 on Amazon. Christian http://www.dowski.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cryptography Toolkit
On Apr 1, 2005 6:45 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > It works if you make a new XOR object for the decryption: > > from Crypto.Cipher import XOR > > obj_xor = XOR.new("string") > str_encrypt = "encrypt this string" > print str_encrypt > > xored = obj_xor.encrypt(str_encrypt) > print xored > > obj_xor = XOR.new("string") > print obj_xor.decrypt(xored) > > Kent Excellent !! Many thanks Kent. -- _ ( ) Mark Thomas ASCII ribbon campaign X www.theswamp.org - against HTML email / \ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A Newbie Printing Question
> > 1) For plain text use the old DOS trick of sending output direct > > to the PRN: file/device - I can't remember if this still works > > in XP but I can't think why not... > > The only reason I can think of is that Windows XP is not directly based on > DOS, wereas the other versions were. In so doing, they have lost a lot of > compatibility with many things. Old DOS games no longer work, some DOS > commands do not work in their mock command prompt, etc. Whatever the reason, I can't seem to open the PRN or LPT devices for output... Also tried the USB002 port which my printer claims to be connected to, so it looks like XP finally kills easy PC printing... I'll be sticking to my HTML technique from now on I guess. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sorting more than one list
> Yikes! Alan must have been up too late. They are not the same at all. > Alan's code creates a list containing *every combination* of one > element from each source list: Oops! Blush... Lack of testing I'm afraid, I checked the syntax worked but not the actual results! Thing is, I knew about zip but thought it was deprecated so decided to try a comprehension instead. Lesson: stick with what you know! :-) Alan G. PS. My posts seem to be taking a long time to make it to the digest. I only got this at 5:30pm but posted it before 10 last night... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Module Loop doesn't work (Joseph Q.)
Hi, I have some code on a geek dictionary that I'm making where the command geeker() opens a module for the "real" geek dictionary (where you can type a word to see what it is geekified). Supposedly, you type lobby() to go back to what I call the lobby (where you can get info on the web site and email and version). But it just loops back to the Geeker>>> prompt where you type the word that you want geekified. I even tried having it restart the whole program by importing the index module that I wrote. But it still won't restart the program! Thanks, Joseph Q. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: Module Loop doesn't work (Joseph Q.)
Joseph Quigley wrote on Fri, 01 Apr 2005 10:07:08 -0600: > I have some code on a geek dictionary that I'm making where the command > geeker() opens a module for the "real" geek dictionary (where you can type > a word to see what it is geekified). Supposedly, you type lobby() to go > back to what I call the lobby (where you can get info on the web site and > email and version). But it just loops back to the Geeker>>> prompt where > you type the word that you want geekified. I even tried having it restart > the whole program by importing the index module that I wrote. But it still > won't restart the program! Without seeing your code, I doubt anyone will be able to solve your problem except by pure chance. In addition to that, I'm confused by the use of function calls in what seems te be essentially a menu system. Speaking in general terms, the way you could handle this is as follows: - have a main menu loop (what you call the lobby) which accepts user input and based on that input calls other functions which perform certain tasks (e.g. open a webpage or go to the dictionary part) - the dictionary part would in turn be another loop accepting words as input which get 'translated', until the user gives a blank string or whatever as input in order to terminate the loop (and automatically fall back into the loop of the lobby) -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] random import errors?
I have a python script that runs on my webserver every fifteen minutes. It has run for several months with absolutely no problems. Suddenly, yesterday morning I got an email from cron with an import error for sre_constants (see below) I logged in with ssh, manually ran the script and got the same error. started a Python interpreter shell, did "import sre_constants" and got no error. Exited, then ran the script again...and got an error importing 'string'. I manually started up Python interpreter again and imported string, again with no error. Then I exited and ran the script, and it ran fine with no errors. I got another such email from cron at 2:30am today ... anyone have any idea what would cause such a seemingly random problem after months of working fine? (sample traceback is below) -Jay 'import site' failed; use -v for traceback Traceback (most recent call last): File "/usr/local/bin/last_update", line 7, in ? import os, glob, time File "/usr/lib/python2.2/glob.py", line 4, in ? import fnmatch File "/usr/lib/python2.2/fnmatch.py", line 13, in ? import re File "/usr/lib/python2.2/re.py", line 27, in ? from sre import * File "/usr/lib/python2.2/sre.py", line 97, in ? import sre_compile File "/usr/lib/python2.2/sre_compile.py", line 15, in ? from sre_constants import * ImportError: No module named sre_constants ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to setup gnu.py
I grabbed this from the docs: Gnuplot.py uses Python distutils and can be installed by untarring the package, changing into the top-level directory, and typing "python setup.py install". The Gnuplot.py package is pure Python--no compilation is necessary. On Mar 30, 2005 11:13 PM, jrlen balane <[EMAIL PROTECTED]> wrote: > hi! i don't know if this is the proper forum but i'll ask anyway... > > how am i going to setup gnu.py(or gnuplot.py) gnuplot with python??? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Launching a file browser
On Mar 31, 2005 2:14 PM, Mike Hall <[EMAIL PROTECTED]> wrote: > > >> It's been too long since I used Python on MacOSX, but IIRC you can't > >> just run a Python GUI program from the shell. Or something like > >> that...you should ask this one on the python-mac SIG mailing list: > >> http://www.python.org/sigs/pythonmac-sig/ > >> > >> Kent > > I'm unclear on why a command like webbrowser.open() will comfortably > launch your default web browser (in my case Safari), but something as > ubiquitous to an OS as a file browser has special needs to launch. At the OS level, these two actions are *completely* different. The webbrowser module launches an entirely separate program in its own independent process, where the "file browser" is opening a standard dialog inside of the current process and dependent upon the current process' message loop. (AFAIK, every GUI environment uses some sort of message/event loop...) I don't know Macs, but on Windows, the closest "file browser" parallel to what the webbrowser module is doing would be os.system("explorer.exe"), which launches a separate program in an independent process. However, if you're trying to get the results of the file selection back into your own app, you need to do the file browsing within your own process (or explicitly use some form of inter-process communication). In order to use a GUI file-browsing dialog, you need to follow all the rules for a GUI program. Jeff Shannon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] random import errors?
On Apr 1, 2005 3:20 PM, Jay Loden <[EMAIL PROTECTED]> wrote: > I have a python script that runs on my webserver every fifteen minutes. It > has run for several months with absolutely no problems. Suddenly, yesterday > morning I got an email from cron with an import error for sre_constants (see > below) Since you're able to import these files manually, it's unlikely to be a problem with your Python installation. I'd suggest trying to figure out what changed between the day before yesterday and yesterday. I'm just guessing here, but I'd expect that this is probably related to either permissions or environment variables. Jeff Shannon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython / Tkinter Grid
Thanks for the feedback. I should clarify - I find wxPython restrictive & fiddly in terms of trying to use a fully featured set of widgets, which are written in C++, trying to use them through a not overly documented Python wrapper. I love Pythoncard more and more. Regards, Liam Clarke On Apr 1, 2005 10:35 PM, Michael Lange <[EMAIL PROTECTED]> wrote: > On Fri, 1 Apr 2005 09:11:20 +0100 > "Alan Gauld" <[EMAIL PROTECTED]> wrote: > > > > I know a wxPython grid is totally different to a Tkinter grid, but > > is > > > there a Tkinter equivalent of a wxPython grid? I'm finding wxPython > > to > > > be fiddly and restrictive... > > > > Then Tkinter will be more so. Tk is a fairly basic toolkit, fine for > > wrapping a command line app in a glossy front end but not for > > sophisticated GUI work. > > > > There is no grid component in Tk out of the box, but some add on > > toolkits > > supply one. Try searching on the Vaults of Parnassus or on the > > ActiveState site if you are determined to try Tkinter... > > > > Alan G. > > > > Or look here: > > http://tkinter.unpythonic.net/wiki/Widgets > > There is a number of links to table widget implementations in Tkinter o nthe > wiki page. > > I hope this helps > > Michael > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor