[Tutor] Why subclassing exceptions?

2011-09-27 Thread Mac Ryan
On Wed, 28 Sep 2011 09:58:49 +1000 Steven D'Aprano wrote: > Mac Ryan wrote: > > > raise BaseException('Something is wrong here!') > > Never raise BaseException directly! BaseException is the very top of > the exception hierarchy, you should raise the *most* specific > exception you can, n

Re: [Tutor] raw_input() slice list

2011-09-27 Thread bob gailer
On 9/27/2011 11:18 PM, questions anon wrote: I would like to use user_input() to decide how to slice a list. This works fine until I try to leave it blank to try and select the whole list [:] I have posted the section of interest below and the error I get when I try to press enter. Further belo

Re: [Tutor] map one file and print it out following the sequence

2011-09-27 Thread lina
Hi, Thanks for both of your reply. File 1 is: 3 C 1 CUR C19 10.200 12.0110 4 CR1 1 CUR C20 1 -0.060 12.0110 5HC 1 CUR H20 10.060 1.0080 File 2 is: ATOM 2 H20 CUR 1 30.338 28.778 -6.812 1.

[Tutor] raw_input() slice list

2011-09-27 Thread questions anon
I would like to use user_input() to decide how to slice a list. This works fine until I try to leave it blank to try and select the whole list [:] I have posted the section of interest below and the error I get when I try to press enter. Further below that is the entire code. Any feedback will be g

Re: [Tutor] help with a recursive function

2011-09-27 Thread Alan Gauld
On 27/09/11 19:32, c smith wrote: i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. Others have dealt with the specifics. If you really want to learn how to

Re: [Tutor] help with a recursive function

2011-09-27 Thread Steven D'Aprano
Mac Ryan wrote: raise BaseException('Something is wrong here!') Never raise BaseException directly! BaseException is the very top of the exception hierarchy, you should raise the *most* specific exception you can, not the least specific. BaseException isn't even just for errors, it's al

Re: [Tutor] help with a recursive function

2011-09-27 Thread Steven D'Aprano
c smith wrote: hi list, i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. Your flow is fine. You just forget to return anything in two of the three branches

Re: [Tutor] My code works but it is a little bit broken.

2011-09-27 Thread brandon w
That was my problem. I had the "insert" function. I don't know why I did not see that before or why I even put that in there. Thank you for your help once again. On Tue, Sep 27, 2011 at 6:43 AM, Alan Gauld wrote: > On 27/09/11 02:32, brandon w wrote: > >> The fields take the initial value and mul

Re: [Tutor] map one file and print it out following the sequence

2011-09-27 Thread Prasad, Ramit
>I have file 1: cur.itp > > 1   CH3 1  CUR  C1 1    0.066  15.0350   > 2    OA 1  CUR  O1 1   -0.183  15.9994   > 3 C 1  CUR  C2 1    0.126  12.0110   >and file 2: procesed.pdb >ATOM  1  H52 CUR 1  33.502  30.958  -9.83

Re: [Tutor] help with a recursive function

2011-09-27 Thread Mac Ryan
On Tue, 27 Sep 2011 14:32:00 -0400 c smith wrote: > hi list, > i understand the general idea of recursion and if I am following well > written code I can understand how it works, but when I try to write > it for myself I get a bit confused with the flow. > I was trying to turn an ackerman functio

Re: [Tutor] map one file and print it out following the sequence

2011-09-27 Thread Alan Gauld
On 27/09/11 14:45, lina wrote: Hi, I have file 1: cur.itp 1 CH3 1 CUR C1 10.066 15.0350 2OA 1 CUR O1 1 -0.183 15.9994 3 C 1 CUR C2 10.126 12.0110 and file 2: procesed.pdb ATOM 1 H52 CUR 1

[Tutor] help with a recursive function

2011-09-27 Thread c smith
hi list, i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. I was trying to turn an ackerman function into python code for practice and I tried writing it like th

Re: [Tutor] How Python handles data (was guess-my-number programme)

2011-09-27 Thread Steven D'Aprano
Wayne Werner wrote: When you do something like this in C: int x = 0; int y = 0; What you have actually done behind the scenes is allocated two bytes of memory(IIRC that's in the C spec, but I'm not 100% sure that it's guaranteed to be two bytes). Perhaps they are near each other, say at addres

[Tutor] map one file and print it out following the sequence

2011-09-27 Thread lina
Hi, I have file 1: cur.itp 1 CH3 1 CUR C1 10.066 15.0350 2OA 1 CUR O1 1 -0.183 15.9994 3 C 1 CUR C2 10.126 12.0110 4 CR1 1 CUR C3 1 -0.020 12.0110 5HC 1 CUR

[Tutor] How Python handles data (was guess-my-number programme)

2011-09-27 Thread Wayne Werner
On Sat, Sep 24, 2011 at 2:58 AM, Kĩnũthia Mũchane < kinuthia.much...@gmail.com> wrote: > ** > On 09/23/2011 11:28 PM, Wayne Werner wrote: > > > >>> tries = 1 > >>> tries > 1 > > The variable 'tries' now contains the value 1 (In Python this is not > technically true, but it's useful to describe

Re: [Tutor] password loop

2011-09-27 Thread Wayne Werner
On Fri, Sep 23, 2011 at 5:56 PM, ADRIAN KELLY wrote: > Can anyone help me with the programme below; i hope you can see what i am > trying to do, if i enter the wrong password the loop goes on forever and if > i enter the right one nothing is printed... > i am a newbieall comments welc

Re: [Tutor] My code works but it is a little bit broken.

2011-09-27 Thread Alan Gauld
On 27/09/11 02:32, brandon w wrote: The fields take the initial value and multiply it to get the amount. The problem in in the callback function. It uses the event to clear a field, but when the mouse enters a second time it adds a numeric value. This is a semantic error. It is not doing what I