Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)
On Tue, 20 Sep 2005, R. Alan Monroe wrote: math.degrees(_) --- in all my time on tutor I have never noticed this underscore trick before That *is* cool. I've usually done something like: a+ 3*b +(5*ht/9) * 32 9936254.2 Then use the up-arrow key to get a+ 3*b +(5*ht/9) * 32 and edit it toL x = a+ 3*b +(5*ht/9) * 32 foo(x) The underscore's a nice stepsaver. And limiting it to the interpreter avoids perlish abuse. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Editors (particualrly Vim)
I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) - collapsible code (to collapse def's etc) - automatic code coloring (that's easily changeable) - auto-completion of namespaces - easy to run scripts from the editor (a shortcut key to run them or something) As I also do a lot of html, css and javascript it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. My various questions are: What other features should I be looking for? What would be the best editor for a beginner to start using, with a view to the long term? Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
comments are inline... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ed Singleton Sent: Wednesday, September 21, 2005 9:00 AM To: tutor@python.org Subject: [Tutor] Python Editors (particualrly Vim) I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) [george]: Emacs works great with this if you have python mode. Eclispe is the same. - collapsible code (to collapse def's etc) [george]: Eclipse is a little easier to perform this, but you can hide lines in Emacs as well. In emacs things are just a bit, less visual than eclipse. - automatic code coloring (that's easily changeable) [george]: Pretty much any editor will provide with this type of functionality. - auto-completion of namespaces [george]: Emacs does not (or I should say I have not found) any type of mode for code complete in python. There are rumors with improvements with CEDET(intellisense) for python, I haven't been able to use them. Eclipse with PyDEV works great, and if you are hardcore linux Eric3 will work too. Although you can run Eric3 on win32 there are a few extra steps needed to install. Also if you work in a commercial development shop, QT licensing for Eric3 might be an issue? - easy to run scripts from the editor (a shortcut key to run them or something) [george]: Emacs provides you a shell for which you can execute a script. You can extend lisp in Emacs as well, which is extremely flexible. I am not sure with eclipse regarding external scripts since I have just recently converted to eclipse from emacs(gasp!).I know you can call up python in interactive mode from eclipse, but I not sure how to call something likemyfoo.bat or myfoo.sh. As with anything in eclipseI am sure there has to be some type of plug-in or something for it. As I also do a lot of html, css and javascript it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. [george]: Lots of editors will support various mode. As for the code completion in javascipt and html I do not have an answer for those. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. [george]: Even though I am some what moving away from emacs, it is still a great editor. I am sure vim is good too, just my preference to use emacs. For mouse support Try including this in your .emacs file (autoload 'mwheel-install mwheel Enable wheely mouse) (mwheel-install) Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. [george]: I think that is fine, I do not have much experience with vim. I only use it about 5% out of the day, hopefully someone else could help you out. My various questions are: What other features should I be looking for? [george]: I think you have them covered You might want to look at integrations with source control (cvs, svn, etc.) too. Also debuggers should be included as well. What would be the best editor for a beginner to start using, with a view to the long term? [george]: I think that is really user preference. Try them all out, you will most likely fall into which one fits your own needs. Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? [george]: check out sourceforge or freshmeat for add-ons and other modes. [george] Good luck [/george] Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)
Okay thanks a lot everyone. Bernard On 9/20/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, I have this little math problem. I have this formula from wich I get a dot product between two vectors. cos(ß) = A.B / |A|.|B| = -0.0634 So this would give me radians, right? No, it's the cosine of ß, which has no units (a cosine is a ratio of two lengths) Then if I use math.degrees( -0.0634 ) This gives me a value of -3.6325524211294193. However I have a book in front of me who says I should get a value of 93.635 degrees. m Btw, in the book, the equation is written ß = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe I'm just interpreting this wrong? The -1 means inverse. You have cos(ß) = -0.0634 - you want to find the angle whose cosine is -0.0634, i.e. (inverse cosine)(-0.0634). Another name for cos-1 is arccosine. In Python it is math.acos(): import math math.acos(-0.0634) 1.6342388771557625 math.degrees(_) 93.634990377223801 Kent Thanks Bernard ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] installation programs
Hello, I want to create an installation program. Can anyone tell me what the best program would be to use... maybe inno setup or install shield? do these work with python programs? do they require programming in another language? thanks. Jeff___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Error frameworks
Hi Is there any particular standard or approach that I should use for an error framework? For example, suppose I have a set of functions that call one another, and an error is triggered. I want an error message to be passed back to the user, so I could: 1. have an error message passed back to each called function until it bubbles up to a point to be passed back to the user in some meaningful way. 2. have a singleton error object updated. 3. ?? What do most people use? Is there any url that you could point me to that would help educate me on this point? Thanks ds ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error frameworks
DS wrote: Hi Is there any particular standard or approach that I should use for an error framework? For example, suppose I have a set of functions that call one another, and an error is triggered. I want an error message to be passed back to the user, so I could: Raise an exception, either a built-in if one is appropriate, or one that you define. http://docs.python.org/tut/node10.html tells you how http://docs.python.org/lib/module-exceptions.html lists the built-in exceptions and what they mean 1. have an error message passed back to each called function until it bubbles up to a point to be passed back to the user in some meaningful way. 2. have a singleton error object updated. Both these approaches have several drawbacks: - Errors are easy to ignore or forget to handle - Client code gets cluttered up with error-handling code Kent 3. ?? What do most people use? Is there any url that you could point me to that would help educate me on this point? Thanks ds ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
Uh oh, looks like you're begging for an editor war. That said, I'm in the vim camp. It can do everything you specified for all of the languages you mention (well, I'm not sure about collapsible code...web search...aha![1]). After using it for four years, I'm still learning new tricks (see, for example, this page I found today on indentation[2]). vim's extendable with python scripts, but a lot of what you need for coding is already built in. I find most of my info either in the help manual that comes with it (:h) or at vim.org. gsf [1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt [2] http://www.vim.org/tips/tip.php?tip_id=83 On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) - collapsible code (to collapse def's etc) - automatic code coloring (that's easily changeable) - auto-completion of namespaces - easy to run scripts from the editor (a shortcut key to run them or something) As I also do a lot of html, css and javascript it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. My various questions are: What other features should I be looking for? What would be the best editor for a beginner to start using, with a view to the long term? Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
No editor wars here, my suggestion as I tried to state below is use what you like. Try'em all and take them for a test spin. Granted I might be slightly biased towards eclipse/emacs.but that is just my world :) Just out of curiosity, does vim have code completion for python? Cheers -george -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabriel Farrell Sent: Wednesday, September 21, 2005 12:56 PM To: tutor@python.org Subject: Re: [Tutor] Python Editors (particualrly Vim) Uh oh, looks like you're begging for an editor war. That said, I'm in the vim camp. It can do everything you specified for all of the languages you mention (well, I'm not sure about collapsible code...web search...aha![1]). After using it for four years, I'm still learning new tricks (see, for example, this page I found today on indentation[2]). vim's extendable with python scripts, but a lot of what you need for coding is already built in. I find most of my info either in the help manual that comes with it (:h) or at vim.org. gsf [1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt [2] http://www.vim.org/tips/tip.php?tip_id=83 On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) - collapsible code (to collapse def's etc) - automatic code coloring (that's easily changeable) - auto-completion of namespaces - easy to run scripts from the editor (a shortcut key to run them or something) As I also do a lot of html, css and javascript it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. My various questions are: What other features should I be looking for? What would be the best editor for a beginner to start using, with a view to the long term? Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] installation programs
Hi Jeff,Most people seem to use a combination of py2exe, and either Inno Setup or NSIS. InstallShield is commercial, and, well, you have to pay for it. py2exe gives you the python interpreter, and all the libraries your program needs in a tidy little package, so unless the computers you are installing to have python and any external libraries you are using already installed, you will need to use that, or something similar. It lets people just install and run. Inno Setup is easy if you don't need anything fancy, ie a simple install made with it's wizard. Packaging things up with py2exe will likely be the tricky part, at least if you start trimming it down manually, or run into any snags. Otherwise it's a breeze. NSIS has a scripting language built in, which does indeed entail learning another language(sorta). I haven't used it, however, so there could be lots you can do without touching the scripting bit. py2exe: http://starship.python.net/crew/theller/py2exe/ NSIS: http://nsis.sourceforge.net/Good luck!On 9/21/05, Jeff Peery [EMAIL PROTECTED] wrote: Hello, I want to create an installation program. Can anyone tell me what the best program would be to use... maybe inno setup or install shield? do these work with python programs? do they require programming in another language? thanks. Jeff ___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Stopping a shell process started with system()
Hi all, I'm trying to write a simple front end for a commandline application (some of the people I'm working with get the shakes if they have to use the commandline) in Windows. I was using os.system() to execute a command, and that works fine, but the only way I know to stop the external program is to hit CTRL-C. On *nix, as I understand it, you could create a Popen3 class instance, which would have the pid as a property of the class, which can be used to call a kill on that pid to stop the program. But, indications are that this is not available for Windows, so I'm wondering if there is a better option than os.system() or if there is just something I'm missing. Any help would be appreciated. I'm using Python 2.3 on Win 2k. Sean -- ***Please note new email address: [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] FW: Python Editors (particualrly Vim)
forwarding. From: Pujo Aji [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 21, 2005 2:39 PMTo: George FlahertySubject: Re: [Tutor] Python Editors (particualrly Vim) I tried pydev, xemacs, komodo, vim, wingide, scite, drPython, pype, idle Each has each own strength point. If I choose the three of them I will choose: 1. wingide (good intellisense, but you have to setup some preferences to suit your need) 2. komodo (has good colour choice) 3. scite (very simple) All are great and I use all of the three. You can only try one by one and decide which one is good for you. Sincerely Yours, pujo On 9/21/05, George Flaherty [EMAIL PROTECTED] wrote: No editor wars here, my suggestion as I tried to state below is use what you like. Try'em all and take them for a test spin. Granted I might be slightly biased towards eclipse/emacs.but that is just my world :) Just out of curiosity, does vim have code completion for python?Cheers-george-Original Message-From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Gabriel FarrellSent: Wednesday, September 21, 2005 12:56 PMTo: tutor@python.orgSubject: Re: [Tutor] Python Editors (particualrly Vim) Uh oh, looks like you're begging for an editor war.That said, I'm in the vim camp.It can do everything you specified for all of the languages you mention (well, I'm not sure about collapsible code...web search...aha![1]).After using it for four years, I'm still learning new tricks (see, for example, this page I found today on indentation[2]). vim's extendable with python scripts, but a lot of what you need for coding is already built in.I find most of my info either in the help manual that comes with it (:h) or at vim.org .gsf[1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt[2] http://www.vim.org/tips/tip.php?tip_id=83 On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) - collapsible code (to collapse def's etc) - automatic code coloring (that's easily changeable) - auto-completion of namespaces - easy to run scripts from the editor (a shortcut key to run them or something) As I also do a lot of html, css and _javascript_ it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. My various questions are: What other features should I be looking for? What would be the best editor for a beginner to start using, with a view to the long term? Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? Thanks Ed ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor___Tutor maillist- Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor___Tutor maillist- Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] cgi.FieldStorage to int
I'm trying to get a cgi.FieldStorage into an int. The input is in numeric form, as it is provided by an option drop-down box. However, when I try timestable = int(form.getvalue('timestable')) I get an error that the type is None - I guess this is because FieldStorage is a class. However, I've trawled around trying to get this field into an integer but without any luck. Any pointers appreciated. TIA Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error frameworks
(Please reply to the tutor list, not to me privately) DS wrote: Thanks for looking at my problem. Let me try to explain what bothers me about raising an error: Below is a brain-dead example of one function calling another which calls another. If in function3 I raise an error, function2 properly catches an error, but function1 doesn't have a clue what went wrong. However, if I want to have function provide the notification and/or handling of the error messages back to the user, then I must have a means of propagating that error back up the line. In this example, since the error is given back as a string rather than a numeric, it still shows an error, but for general purposes this seems like a bad approach. I've thought of having a tuple returned (answer, error) which would carry the message back to function 1, but that seems awkward as well. Generally, you want to catch the exception at the level that knows what to do about it. Your function2() isn't handling the exception in any meaningful sense, it is just converting it to a magic return value. You might as well just use magic return values everywhere if you do this. Even function1() seems like it is too low-level to handle the error since it is also just converting the error to a magic return. For short, simple scripts you can often omit exception handling completely. Any raised exceptions will propagate to the interpreter which will print a stack trace and exit. This is very handy - you get to see exactly where the error occured and the details of the exception type and message. This style may also be appropriate for handling any fatal error even in a complex script. For more complex scripts, for example a server or GUI app, or a script that processes many items, you probably don't want to exit the script on an error. In this case you might have a high-level exception handler that logs the exception and continues. For example here is a loop that processes a list of items, if there is an error processing an item a traceback is printed and the processing continues: import traceback def processLotsOfStuff(listOfStuff): for item in listOfStuff: try: processOneItem(item) except: print 'Error processing item', item traceback.print_exc() Kent Thanks for your help. ds *def* function1(value): /# to simply this just calls the next function/ *try*: value1 = function2(value) value1 += 1 *except*: value1 = 'but what is the error?' *return* value1 *def* function2(value): /# to simply this just calls the next function/ *try*: value2 = function3(value) *except*: value2 = 'error' *return* value2 *def* function3(value): /# let's say real work is performed here/ /# the input has to be real number, for example/ *if* value 0: *raise* this is bad, very bad *else*: *return* value + 1 Kent Johnson wrote: DS wrote: Hi Is there any particular standard or approach that I should use for an error framework? For example, suppose I have a set of functions that call one another, and an error is triggered. I want an error message to be passed back to the user, so I could: Raise an exception, either a built-in if one is appropriate, or one that you define. http://docs.python.org/tut/node10.html tells you how http://docs.python.org/lib/module-exceptions.html lists the built-in exceptions and what they mean 1. have an error message passed back to each called function until it bubbles up to a point to be passed back to the user in some meaningful way. 2. have a singleton error object updated. Both these approaches have several drawbacks: - Errors are easy to ignore or forget to handle - Client code gets cluttered up with error-handling code Kent 3. ?? What do most people use? Is there any url that you could point me to that would help educate me on this point? Thanks ds ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi.FieldStorage to int
Adam Cripps wrote: I'm trying to get a cgi.FieldStorage into an int. The input is in numeric form, as it is provided by an option drop-down box. However, when I try timestable = int(form.getvalue('timestable')) I get an error that the type is None - I guess this is because FieldStorage is a class. However, I've trawled around trying to get this field into an integer but without any luck. My guess is that there is no 'timestable' parameter - are you sure you spelled it the same way in the form? Try adding import sys print sys.stderr, form.keys() to the form, I think this will print a list of available parameters to the console. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi.FieldStorage to int
On 9/21/05, Kent Johnson [EMAIL PROTECTED] wrote: Adam Cripps wrote: I'm trying to get a cgi.FieldStorage into an int. The input is in numeric form, as it is provided by an option drop-down box. However, when I try timestable = int(form.getvalue('timestable')) I get an error that the type is None - I guess this is because FieldStorage is a class. However, I've trawled around trying to get this field into an integer but without any luck. My guess is that there is no 'timestable' parameter - are you sure you spelled it the same way in the form? Try adding import sys print sys.stderr, form.keys() to the form, I think this will print a list of available parameters to the console. Kent Great minds think alike, but alas I'm pretty sure it's not the issue - I've already checked whether timestable existed with: print timestable is..., form.getvalue('timestable') and it displays fine. Adam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi.FieldStorage to int
Adam Cripps wrote: On 9/21/05, Kent Johnson [EMAIL PROTECTED] wrote: Adam Cripps wrote: I'm trying to get a cgi.FieldStorage into an int. The input is in numeric form, as it is provided by an option drop-down box. However, when I try timestable = int(form.getvalue('timestable')) I get an error that the type is None - I guess this is because FieldStorage is a class. However, I've trawled around trying to get this field into an integer but without any luck. Please post the exact error message including the stack trace. Also, what prints when you print form.getvalue('timestable') Kent My guess is that there is no 'timestable' parameter - are you sure you spelled it the same way in the form? Try adding import sys print sys.stderr, form.keys() to the form, I think this will print a list of available parameters to the console. Kent Great minds think alike, but alas I'm pretty sure it's not the issue - I've already checked whether timestable existed with: print timestable is..., form.getvalue('timestable') and it displays fine. Adam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] dialog boxes for Windows
Hello all of you, I want to use yes/no-, text-, info-, checklist- dialog boxes in my image manipulation program (on a Windows XP Pro system using python 2.2 and 2.3). What is the best way to do this? Do peopel have some examples or links? I want to know which python modules are needed and where to get. Thanks for your feedback. All the best, Victor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python, vim, indentation, and wrapped lines
I use Vim as my primary Python code editor. I've always wondered if there is a way to make wrapped lines take on the indentation of the previous line. Of course I mean *in the display only*, since I don't want any newlines introduced. This would also be handy for me when editing indented html/xml documents. Anyone know how to do this in vim? -- Poor Yorick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] dialog boxes for Windows
Victor Reijs wrote: Hello all of you, I want to use yes/no-, text-, info-, checklist- dialog boxes in my image manipulation program (on a Windows XP Pro system using python 2.2 and 2.3). What is the best way to do this? If your program does not have a GUI and you want to add some simple dialog boxes then EasyGUI might work for you: http://www.ferg.org/easygui/ If your needs go beyond this then you will have to choose a GUI toolkit and learn to use it. The two most popular GUI toolkits for Python on Windows seem to be Tkinter (which is included with Python, see http://wiki.python.org/moin/TkInter for info) and wxPython (http://www.wxpython.org). Which is better is a matter of opinion. I think the general consensus is that Tkinter is easier to use for simple projects and wxPython has more variety of widgets and may be better for a complex GUI. Kent Do peopel have some examples or links? I want to know which python modules are needed and where to get. Thanks for your feedback. All the best, Victor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error frameworks
(Please reply to the tutor list, not to me privately) whoops Generally, you want to catch the exception at the level that knows what to do about it. Your function2() isn't handling the exception in any meaningful sense, it is just converting it to a magic return value. You might as well just use magic return values everywhere if you do this. Even function1() seems like it is too low-level to handle the error since it is also just converting the error to a magic return. For short, simple scripts you can often omit exception handling completely. Any raised exceptions will propagate to the interpreter which will print a stack trace and exit. This is very handy - you get to see exactly where the error occured and the details of the exception type and message. This style may also be appropriate for handling any fatal error even in a complex script. For more complex scripts, for example a server or GUI app, or a script that processes many items, you probably don't want to exit the script on an error. In this case you might have a high-level exception handler that logs the exception and continues. For example here is a loop that processes a list of items, if there is an error processing an item a traceback is printed and the processing continues: I think you are correct that I haven't been letting my raised errors propagate high enough. That helps. Thanks very much. ds ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi.FieldStorage to int
On 9/21/05, Kent Johnson [EMAIL PROTECTED] wrote: Adam Cripps wrote: On 9/21/05, Kent Johnson [EMAIL PROTECTED] wrote: Adam Cripps wrote: I'm trying to get a cgi.FieldStorage into an int. The input is in numeric form, as it is provided by an option drop-down box. However, when I try timestable = int(form.getvalue('timestable')) I get an error that the type is None - I guess this is because FieldStorage is a class. However, I've trawled around trying to get this field into an integer but without any luck. Please post the exact error message including the stack trace. Also, what prints when you print form.getvalue('timestable') Kent Ok - thanks for the tipoff Kent - the problem is now solved. My timestable was returning as a list, as it was being populated in a loop (for each question in the times table). Once I moved it outside of the loop, the int(form.getvalue('timestable') works fine. Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
I don't believe there's any kinds of wars on this mailing group. :) I found this Python Vim code completion thing in my searches today: http://freshmeat.net/projects/pydiction/ Don't know how good it is, but it looks like it'd do the job. Ed On 21/09/05, Gabriel Farrell [EMAIL PROTECTED] wrote: Uh oh, looks like you're begging for an editor war. That said, I'm in the vim camp. It can do everything you specified for all of the languages you mention (well, I'm not sure about collapsible code...web search...aha![1]). After using it for four years, I'm still learning new tricks (see, for example, this page I found today on indentation[2]). vim's extendable with python scripts, but a lot of what you need for coding is already built in. I find most of my info either in the help manual that comes with it (:h) or at vim.org. gsf [1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt [2] http://www.vim.org/tips/tip.php?tip_id=83 On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: I've been trying to decide which editor to use to edit Python (on Windows mostly). My wishlist of features would be: - automatic code formatting (indentation etc) - collapsible code (to collapse def's etc) - automatic code coloring (that's easily changeable) - auto-completion of namespaces - easy to run scripts from the editor (a shortcut key to run them or something) As I also do a lot of html, css and javascript it would be cool to have an editor that could also handle them, in which case I would want the same features for those languages, as well as the ability to write macros, scripts, etc in python. Having looked at loads of editors, I've ended up looking at emacs and vim. Emacs seems too difficult with not enough support for using the mouse. Vim seemed better, and I get the impression that it is possible to use python to script the editor, but I can't find much information on using vim as a python editor on windows. My various questions are: What other features should I be looking for? What would be the best editor for a beginner to start using, with a view to the long term? Where can I find some authoritative information about setting emacs or vim up as a fully featured python editor? Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Calling Modules in ActiveState 2.4
Working my way through Alan Gauld's tutorial, and I am on the section on modules. When I call: import sys sys.exit() I get a traceback error saying it needs more input Same when I do: import sys print sys.path() Both of these work if I do sys.exit or print sys.path without the parentheses. Is this new behavior in Activstate 2.4, or do I need to set an environment variable? Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Calling Modules in ActiveState 2.4
For exit: You need to put an argument (more input) : import sys sys.exit(0) The argument of exit is the return value of your script (0 = okay, other = problem). sys.path is an attribute (of type list) of sys not a function. So don't put () after path. I hope it will help. Damien. Bob Nienhuis wrote: Working my way through Alan Gauld's tutorial, and I am on the section on modules. When I call: import sys sys.exit() I get a traceback error saying it needs more input Same when I do: import sys print sys.path() Both of these work if I do sys.exit or print sys.path without the parentheses. Is this new behavior in Activstate 2.4, or do I need to set an environment variable? Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Calling Modules in ActiveState 2.4
Hi Bob, Bob, when you see these kinds of errors, please don't paraphrase the error message. You mentioned: When I call: import sys sys.exit() I get a traceback error saying it needs more input Instead of putting the error in your own, just copy-and-paste the error. Don't worry about verbosity here: we really like seeing good error messages. Honest! *grin* The reason this is important is because when things break, there could be any number of reasons why. We have to be able to know that the problems we're seeing are the same problems that you're seeing: otherwise, we might be fixing something that has nothing to do with your particular problem. The code you have written works for me personally, so there must be something context-sensitive going on here that I'm not seeing yet. That's why, when we're debugging, we need to see the exact error message that you're seeing too: it's just one of those valuable additional clues that we use when figuring out what's going on. Good luck to you! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Calling Modules in ActiveState 2.4
When I do: import sys sys.exit(0) I get: Traceback (most recent call last): File C:\Python24\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py, line 141, in fire rc = apply(binding.handler, args) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 478, in ProcessEnterEvent if self.interp.runsource(source, interactive input): # Need more input! File C:\Python24\lib\code.py, line 87, in runsource self.runcode(code) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 257, in runcode exec code in self.globals, self.locals File interactive input, line 1, in ? SystemExit: 0 BobOn 9/21/05, Damien Gouteux [EMAIL PROTECTED] wrote: For exit: You need to put an argument (more input) : import sys sys.exit(0) The argument of exit is the return value of your script (0 = okay, other = problem). sys.path is an attribute (of type list) of sys not a function. So don't put () after path. I hope it will help. Damien. Bob Nienhuis wrote: Working my way through Alan Gauld's tutorial, and I am on the section on modules. When I call: import sys sys.exit() I get a traceback error saying it needs more input Same when I do: import sys print sys.path() Both of these work if I do sys.exit or print sys.path without the parentheses. Is this new behavior in Activstate 2.4, or do I need to set an environment variable? Bob ___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Calling Modules in ActiveState 2.4
Just tried again. Got: import sys sys.exit() Firing event 'ProcessEnter' failed. Traceback (most recent call last): File C:\Python24\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py, line 141, in fire rc = apply(binding.handler, args) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 478, in ProcessEnterEvent if self.interp.runsource(source, interactive input): # Need more input! File C:\Python24\lib\code.py, line 87, in runsource self.runcode(code) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 257, in runcode exec code in self.globals, self.locals File interactive input, line 1, in ? SystemExit sys.exit(0) On 9/21/05, Bob Nienhuis [EMAIL PROTECTED] wrote: When I do: import sys sys.exit(0) I get: Traceback (most recent call last): File C:\Python24\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py, line 141, in fire rc = apply(binding.handler, args) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 478, in ProcessEnterEvent if self.interp.runsource(source, interactive input): # Need more input! File C:\Python24\lib\code.py, line 87, in runsource self.runcode(code) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 257, in runcode exec code in self.globals, self.locals File interactive input, line 1, in ? SystemExit: 0 BobOn 9/21/05, Damien Gouteux [EMAIL PROTECTED] wrote: For exit: You need to put an argument (more input) : import sys sys.exit(0) The argument of exit is the return value of your script (0 = okay, other = problem). sys.path is an attribute (of type list) of sys not a function. So don't put () after path. I hope it will help. Damien. Bob Nienhuis wrote: Working my way through Alan Gauld's tutorial, and I am on the section on modules. When I call: import sys sys.exit() I get a traceback error saying it needs more input Same when I do: import sys print sys.path() Both of these work if I do sys.exit or print sys.path without the parentheses. Is this new behavior in Activstate 2.4, or do I need to set an environment variable? Bob ___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Calling Modules in ActiveState 2.4
On Wed, 21 Sep 2005, Bob Nienhuis wrote: When I do: import sys sys.exit(0) I get: Traceback (most recent call last): File C:\Python24\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py, line 141, in fire rc = apply(binding.handler, args) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 478, in ProcessEnterEvent if self.interp.runsource(source, interactive input): # Need more input! File C:\Python24\lib\code.py, line 87, in runsource self.runcode(code) File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\interact.py, line 257, in runcode exec code in self.globals, self.locals File interactive input, line 1, in ? SystemExit: 0 Ok, good, thanks for the error message: that clears up exactly what's going on. (Actually, that looks like a bug in PythonWin: it should handle that particular situation a little bit more cleanly.) Bob, what's happening is just the nature of the command you're executing: sys.exit() is telling Python to exit. But since the PythonWin text editor itself depends on Python staying up, it rejects the exit command, as it should! Your interpretation that it was asking for more input wasn't accurate. Instead, the error message is saying: The user gave me this interactive input command for me to run, but when I did, it raised an exception that I don't know how to handle. I'll spit out this debugging information for something to inspect. So try different module functions besides sys.exit(). I think things are actually fine: you're just testing out a function that you shouldn't be running on the PythonWin interactive prompt. A different module you can play with is the 'math' module: http://www.python.org/doc/lib/module-math.html Good luck! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor