Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Jim Mooney
Keep the try block small. For example if it's for a call to open(filename, r) the only possible errors (assuming correct syntax) are NameError for using an undefined variable and IOError for specifying a file which doesnt exist. Thanks. Since I'm new at this the error lists I saw just had the

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Bod Soutar
On 22 May 2013 07:20, Jim Mooney cybervigila...@gmail.com wrote: Keep the try block small. For example if it's for a call to open(filename, r) the only possible errors (assuming correct syntax) are NameError for using an undefined variable and IOError for specifying a file which doesnt exist.

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Marc Tompkins
On Tue, May 21, 2013 at 11:25 PM, Bod Soutar bod...@googlemail.com wrote: On 22 May 2013 07:20, Jim Mooney cybervigila...@gmail.com wrote: Keep the try block small. For example if it's for a call to open(filename, r) the only possible errors (assuming correct syntax) are NameError for

Re: [Tutor] still nosing around

2013-05-22 Thread Albert-Jan Roskam
  snip Personally, I recommend you start with doctests rather than nose or unittest. Doctests can also be run using nose, maybe that's also an idea? Nose does doctest, unittest, and its own tests. By default, test files need to have a prefix test_. Unless you specify this either as a

[Tutor] trying to split or rpartition the contents of a list

2013-05-22 Thread Stuart Tozer
Hi everyone. I'm stuck on a problem while developing a small tool for Maya. Basically, I have a folder with some filenames in it which have been returned by os.listdir(). These filenames look something like... apple_d.jpg apple_si.jpg apple_sg.jpg box_d.jpg box_si.jpg pumpkin_d.jpg Right now,

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Peter Otten
Andrew Triplett wrote: I am on chapter two for Python Programming working on the challenges and the question is: 1. Create a list of legal and illegal variable names. Describe why each is either legal or illegal. Next, create a list of good and bad legal variable names. Describe why each

Re: [Tutor] trying to split or rpartition the contents of a list

2013-05-22 Thread Amit Saha
Hello, On Wed, May 22, 2013 at 5:49 PM, Stuart Tozer stuto...@gmail.com wrote: Hi everyone. I'm stuck on a problem while developing a small tool for Maya. Basically, I have a folder with some filenames in it which have been returned by os.listdir(). These filenames look something like...

Re: [Tutor] trying to split or rpartition the contents of a list

2013-05-22 Thread Albert-Jan Roskam
forobjectinobjects:sorted(set(object.split('_',1)[0]))cmds.menuItem(label =object,parent =objectMenu) sorted returns the sorted list but you don't assign anything to it. You can either assign it to a variable, or use the .sort method instead. Also, you don't need to specify the maxsplit

Re: [Tutor] trying to split or rpartition the contents of a list

2013-05-22 Thread Stuart Tozer
Thanks very much guys- I'll get back to this when I have a spare moment and let you know how I get on. Cheers, Stu On Wed, May 22, 2013 at 11:06 AM, Albert-Jan Roskam fo...@yahoo.com wrote: forobjectinobjects:sorted(set(object.split('_',1)[0]))cmds.menuItem(label =object,parent

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Matthew Ngaha
On Wed, May 22, 2013 at 6:02 AM, Andrew Triplett andrew139...@yahoo.com wrote: I am on chapter two for Python Programming working on the challenges and the question is: 1. Create a list of legal and illegal variable names. Describe why each is either legal or illegal. Next, create a list of

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-22 Thread eryksun
On Wed, May 22, 2013 at 12:26 AM, Jim Mooney cybervigila...@gmail.com wrote: Actually, I did notice that tests were zero, but the book I am using does not mention needing the word 'test' as part of the regex. There is only so much time in a day and so many books I can buy (and not all

Re: [Tutor] still nosing around

2013-05-22 Thread Walter Prins
Hi, On 22 May 2013 05:26, Jim Mooney cybervigila...@gmail.com wrote: But that brings up a point. Does this mean that if I have to test a module with a lot of subroutines I have to rename every subroutine with 'test' appended? Some quick comments for what it's worth: (One of) the points

Re: [Tutor] still nosing around

2013-05-22 Thread Dave Angel
On 22 May 2013 05:26, Jim Mooney cybervigila...@gmail.com wrote: But that brings up a point. Does this mean that if I have to test a module with a lot of subroutines I have to rename every subroutine with 'test' appended? No, you don't rename the existing functions. But the testing

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 22/05/13 15:46, Jim Mooney wrote: I'm looking at Try..Except Try: some statements Except SomethingError as err: other statements The list of error statements is huge. How do I know which error statement to put in place of SomethingError (or multiple errors for that matter)? Or is

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 22/05/13 16:20, Jim Mooney wrote: Keep the try block small. For example if it's for a call to open(filename, r) the only possible errors (assuming correct syntax) are NameError for using an undefined variable and IOError for specifying a file which doesnt exist. Jim, I don't know who you

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 7:50 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 15:46, Jim Mooney wrote: [...] But don't do this in real code! In real code, the rules you should apply are: 1) never hide programming errors by catching exceptions; 2) errors should only be caught

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 16:20, Jim Mooney wrote: [...} A very important quote from Chris Smith: I find it amusing when novice programmers believe their main job is preventing programs from crashing. ... More experienced

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 22/05/13 23:31, boB Stepp wrote: On Wed, May 22, 2013 at 7:50 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 15:46, Jim Mooney wrote: [...] But don't do this in real code! In real code, the rules you should apply are: 1) never hide programming errors by catching

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 22/05/13 23:37, boB Stepp wrote: On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 16:20, Jim Mooney wrote: [...} A very important quote from Chris Smith: I find it amusing when novice programmers believe their main job is preventing programs from

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
Thanks, Steve, for your last two posts. You have made things much clearer for me. On Wed, May 22, 2013 at 9:49 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 23:37, boB Stepp wrote: On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano st...@pearwood.info wrote: [...] Being a

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Evans Anyokwu
Hi Andrew, I'm sure the exercises at the end of the each chapters are there for you to attempt. Asking for help here without attempting it is not the best way to learn. If however, you've tried something - and it didn't work, by all means ask for help. In the mean time show us what you have so

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-22 Thread Jim Mooney
Please don't reply to digests. Each message has a Message-ID, and replies have an IN-REPLY-TO field that references the ID of the previous message in the thread. By replying to the digest your message has no meaningful Subject, and even if you change the Subject field, it still won't be

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-22 Thread Steven D'Aprano
On 23/05/13 02:13, Jim Mooney wrote: Please don't reply to digests. Each message has a Message-ID, and replies have an IN-REPLY-TO field that references the ID of the previous message in the thread. By replying to the digest your message has no meaningful Subject, and even if you change the

[Tutor] To error statement or not to error statement

2013-05-22 Thread Jim Mooney
I find it amusing when novice programmers believe their main job is preventing programs from crashing. ... More experienced programmers realize that correct code is great, code that crashes could use improvement, but incorrect code that doesn't crash is a horrible nightmare. Then am I right

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-22 Thread eryksun
On Wed, May 22, 2013 at 12:13 PM, Jim Mooney cybervigila...@gmail.com wrote: Please don't reply to digests. Each message has a Message-ID, and replies have an IN-REPLY-TO field that references the ID of the previous message in the thread. By replying to the digest your message has no

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 9:45 AM, Steven D'Aprano st...@pearwood.info wrote: On 22/05/13 23:31, boB Stepp wrote: On Wed, May 22, 2013 at 7:50 AM, Steven D'Aprano st...@pearwood.info wrote: [...] 3) your job as a programmer is *not* to stop your program from raising an error, but to make it

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 23/05/13 02:09, boB Stepp wrote: I was not aware that hardware damage could be caused by poor programming. I am curious; can you give some examples of how this might occur? Does your computer have a DVD drive? Or Blu-Ray? Is it region-locked? Some region-locked drives let you change the

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Marc Tompkins
On Wed, May 22, 2013 at 9:50 AM, boB Stepp robertvst...@gmail.com wrote: I guess I'll pick the first alternative. However, this brings to mind my biggest gripe as a user of software, particularly here at work where the programmer obviously has no medical background: cryptic error messages

[Tutor] Available characters

2013-05-22 Thread Citizen Kant
Does anybody know if there's a Python method that gives or stores the complete list of ascii characters or unicode characters? The list of every single character available would be perfect. Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] Available characters

2013-05-22 Thread eryksun
On Wed, May 22, 2013 at 2:14 PM, Citizen Kant citizenk...@gmail.com wrote: Does anybody know if there's a Python method that gives or stores the complete list of ascii characters or unicode characters? The list of every single character available would be perfect. The unicodedata module

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Albert-Jan Roskam
Subject: Re: [Tutor] try..except - what about that ton of **Error statements? On 23/05/13 02:09, boB Stepp wrote: I was not aware that hardware damage could be caused by poor programming. I am curious; can you give some examples of how this might occur? There used to be a program

[Tutor] Fwd: Available characters

2013-05-22 Thread Citizen Kant
On Wed, May 22, 2013 at 2:14 PM, Citizen Kant citizenk...@gmail.com wrote: Does anybody know if there's a Python method that gives or stores the complete list of ascii characters or unicode characters? The list of every single character available would be perfect. The unicodedata module

Re: [Tutor] Fwd: Available characters

2013-05-22 Thread Jim Mooney
The unicodedata module provides access to the Unicode database that Python uses: http://docs.python.org/2/library/unicodedata#unicodedata.unidata_version That was really useful for another reason. After I checked and saw it was in DLLs, I investigated the other Python DLLs - which had

[Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
I made a simple ear frequency-tester, but I don't want it to go on forever, so I tried stopping it when I pressed a key, as below, but that doesn't work. I did check out keyboard interrupts but they seem unnecessarily complex just to stop a program. I'm not passing keys. Is there something simple

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Marc Tompkins
On Wed, May 22, 2013 at 12:47 PM, Jim Mooney cybervigila...@gmail.comwrote: I made a simple ear frequency-tester, but I don't want it to go on forever, so I tried stopping it when I pressed a key, as below, but that doesn't work. I did check out keyboard interrupts but they seem

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jerry Hill
On Wed, May 22, 2013 at 3:47 PM, Jim Mooney cybervigila...@gmail.comwrote: I made a simple ear frequency-tester, but I don't want it to go on forever, so I tried stopping it when I pressed a key, as below, but that doesn't work. I did check out keyboard interrupts but they seem unnecessarily

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
I've not used it myself, but I believe the KeyboadInterrupt is only generated by one _specific_ keypress. You mentioned that you pressed a key - did you try Control-C? Actually, I did, using Win 7 - and I put exit() in place of pass. I tried ctrl-c, ctrl-x, esc, and del. Windows doesn't seem

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Dave Angel
On 05/22/2013 03:03 PM, Albert-Jan Roskam wrote: Subject: Re: [Tutor] try..except - what about that ton of **Error statements? On 23/05/13 02:09, boB Stepp wrote: I was not aware that hardware damage could be caused by poor programming. I am curious; can you give some examples of how

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 13:24, Jim Mooney cybervigila...@gmail.com wrote: I've not used it myself, but I believe the KeyboadInterrupt is only generated by one _specific_ keypress. You mentioned that you pressed a key - did you try Control-C? Actually, I did, using Win 7 - and I put exit() in place of

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Marc Tompkins
On Wed, May 22, 2013 at 1:30 PM, Jim Mooney cybervigila...@gmail.comwrote: On 22 May 2013 13:24, Jim Mooney cybervigila...@gmail.com wrote: I've not used it myself, but I believe the KeyboadInterrupt is only generated by one _specific_ keypress. You mentioned that you pressed a key - did

Re: [Tutor] keyboard interrupt

2013-05-22 Thread eryksun
On Wed, May 22, 2013 at 4:30 PM, Jim Mooney cybervigila...@gmail.com wrote: Figured it out. Ctrl-C only works in the Windows Command window, not in an editor. Which IDE? In IDLE, your code runs in the main thread of a subprocess (unless IDLE is started with the -n option). A second thread

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 15:05, eryksun eryk...@gmail.com wrote: On Wed, May 22, 2013 at 4:30 PM, Jim Mooney cybervigila...@gmail.com wrote: Figured it out. Ctrl-C only works in the Windows Command window, not in an editor. Which IDE? Wing. But not being able to abort out of a Windows program is a

Re: [Tutor] Available characters

2013-05-22 Thread Steven D'Aprano
On 23/05/13 04:14, Citizen Kant wrote: Does anybody know if there's a Python method that gives or stores the complete list of ascii characters or unicode characters? The list of every single character available would be perfect. There are only 127 ASCII characters, so getting a list of them

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Dave Angel
On 05/22/2013 04:11 PM, Jerry Hill wrote: On Wed, May 22, 2013 at 3:47 PM, Jim Mooney cybervigila...@gmail.comwrote: I made a simple ear frequency-tester, but I don't want it to go on forever, so I tried stopping it when I pressed a key, as below, but that doesn't work. I did check out

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
What do you mean doesn't do anything ? It certainly terminates the loop, which was the intent. Provided of course that something else isn't trapping the Ctrl-C first. It doesn't in Windows proper, using Wing 101. It does exit in the Windows command console. For some reason I forgot ctrl-C is

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread Steven D'Aprano
On 23/05/13 02:09, boB Stepp wrote: I would like to ask some general questions here. Problems can arise from bugs in the operating system, bugs in the programming language(s) being used, bugs in packages/modules being used, bugs in any third party packages being used, etc. Also, whenever any

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Dave Angel
On 05/22/2013 09:46 PM, Jim Mooney wrote: What do you mean doesn't do anything ? It certainly terminates the loop, which was the intent. Provided of course that something else isn't trapping the Ctrl-C first. It doesn't in Windows proper, using Wing 101. Then Wing is changing the behavior,