Re: [Tutor] Finding which list entry is being used, in a for loop

2005-05-19 Thread Kent Johnson
Terry Carroll wrote: > On Tue, 17 May 2005, Kent Johnson wrote: > > >>I often find that the information in the traceback and exception are >>enough to figure out the problem; if not, a few print statements can >>help. You will get better at this with experience. > > > Here's an example where t

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-19 Thread Bernard Lebel
That is very interesting John. Thanks! Bernard On 5/19/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Quoting Bernard Lebel <[EMAIL PROTECTED]>: > > > Well, that was a nice explanation. Thanks once again Kent! > > There is a nice (not too technical) essay on the running speeds of differ

Re: [Tutor] Disable menubar

2005-05-19 Thread jfouhy
Quoting Alberto Troiano <[EMAIL PROTECTED]>: > About disabling the button it would be nice to know if that can be done > , although I made some work around and I managed to restrict the > Toplevels. You can disable buttons and menu items with the state option. Setting state=DISABLED will grey-ou

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Thu, 19 May 2005, Max Noel wrote: > On May 19, 2005, at 23:05, Terry Carroll wrote: > > > Thanks to you both. I think I may need to step up my "development > > environment" beyond emacs and a command line. > > Actually, if you're having problems with debugging your problem, > what you

Re: [Tutor] Disable menubar

2005-05-19 Thread Alberto Troiano
YES That's what I was looking for and I will replace it. I don't like to much the MenuBar from Pmw its different and it does not have all the menu attributes that windows menu have (or maybe I don't know how to use it well :D) About disabling the button it would be nice to know if that can

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Max Noel
On May 19, 2005, at 23:05, Terry Carroll wrote: > Thanks to you both. I think I may need to step up my "development > environment" beyond emacs and a command line. Actually, if you're having problems with debugging your problem, what you should step up is your approach to debugging/testi

Re: [Tutor] kernel serie

2005-05-19 Thread Max Noel
On May 19, 2005, at 23:28, Jonas Melian wrote: > I want get the kernel serie, so 2.x only (2.6 or 2.4) > > info_kernel = platform.release() # get the kernel version > info_kernel = '.'.join(info_kernel.split('.',2)[:2]) > > is there any way of get it in one line only? Based on your code, th

[Tutor] Finding which list entry is being used, in a for loop (was: using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Tue, 17 May 2005, Kent Johnson wrote: > I often find that the information in the traceback and exception are > enough to figure out the problem; if not, a few print statements can > help. You will get better at this with experience. Here's an example where traceback and print statements doesn

[Tutor] kernel serie

2005-05-19 Thread Jonas Melian
I want get the kernel serie, so 2.x only (2.6 or 2.4) info_kernel = platform.release() # get the kernel version info_kernel = '.'.join(info_kernel.split('.',2)[:2]) is there any way of get it in one line only? Thanks in advance! ___ Tutor maillist -

Re: [Tutor] diving into py question

2005-05-19 Thread Max Noel
On May 19, 2005, at 22:46, Chelan Farsight wrote: > Thanks! > You were right about the double underscore, however, I am still > getting the error on line 7...hrmm > any other ideas? > In your original code, the space between if and __main__ is also missing. This may be the source of the e

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Wed, 18 May 2005 [EMAIL PROTECTED] wrote: > Another possibility is to look at this recipe: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65287 On Tue, 17 May 2005, Kent Johnson wrote: > I think this approach to debugging won't scale well and you are just > seeing the tip of the ic

Re: [Tutor] diving into py question

2005-05-19 Thread Chelan Farsight
Thanks! You were right about the double underscore, however, I am still getting the error on line 7...hrmm any other ideas? On 5/19/05, Max Noel <[EMAIL PROTECTED]> wrote: > > On May 19, 2005, at 22:18, Chelan Farsight wrote: > > > I am using the online book Dive Into Python. > > I ran the first

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-19 Thread Bernard Lebel
Well, that was a nice explanation. Thanks once again Kent! Bernard On 5/16/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > > Hi Kent, > > > > So if I undestand you right, mapping a function with map() when it is > > a built-in function will/may be faster than a for loop, but

Re: [Tutor] diving into py question

2005-05-19 Thread Max Noel
On May 19, 2005, at 22:18, Chelan Farsight wrote: > I am using the online book Dive Into Python. > I ran the first program given and have run into an error on line 7 at > the colon. Now I imagine that there is probably a corrections page at > the site, but I am interested in knowing why it won't

[Tutor] diving into py question

2005-05-19 Thread Chelan Farsight
I am using the online book Dive Into Python. I ran the first program given and have run into an error on line 7 at the colon. Now I imagine that there is probably a corrections page at the site, but I am interested in knowing why it won't work as much as what I need to do to correct it. Any hel

Re: [Tutor] Whle Loop to run again.

2005-05-19 Thread Alan G
> I want the program to run again when i input 'run' But, It doesn't... You need another loop, or to ask for input inside the loop. If you always want 100 iterations then prompt for another hundred structure it like: run = raw_input('run or exit? ') while run = 'run': for n in range(100):

Re: [Tutor] dictionary values in strings

2005-05-19 Thread Max Noel
On May 19, 2005, at 20:49, William O'Higgins wrote: > I am trying to discover the syntax for call on a dictionary of > lists by > key and index. > > The data structure looks like this: > > dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\ > 'key3':['li1'li2,'li3','']} > > The keys

Re: [Tutor] dictionary values in strings

2005-05-19 Thread Bernard Lebel
Indeed, dictionaries don't have a .key attribute. Instead, use: # Get list of values for 'key1' aList = dol[ 'key1' ] This would return the list of values you have assigned to 'key1' in the dictionary. Once you got that list, you can look in the list to find out the index of 'lil1' and return i

[Tutor] Disable menubar

2005-05-19 Thread Alberto Troiano
Hey everyone I've read about menubars and I decided to use the MenuBar from PMW instead of Tkinter's The reason is that I couldn't find an example to make a menu with cascade submenus and another cascade submenu inside the submenu and so on. Now I want to ask if somebody knows how to accomplis

[Tutor] dictionary values in strings

2005-05-19 Thread William O'Higgins
I am trying to discover the syntax for call on a dictionary of lists by key and index. The data structure looks like this: dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\ 'key3':['li1'li2,'li3','']} The keys are passed to a function as arguments, and I want the value of the specif

[Tutor] buttons, scrollbar, tkinter

2005-05-19 Thread Ron Alvarado
I was trying to put buttons in, but now I know why it wouldn't work. I'm going to take a look at PMW. Thanks. Ron A ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Finding word in file

2005-05-19 Thread Alan G
> >What are you trying? > >You could simply read through the file line by line using the string > >search methods. Store the previous 2 lines then when found print the > >previous two lines, the current line and then read and print the next > >two lines. > > How? Does your tutorial cover that (i do

Re: [Tutor] Python debugger under Tiger?

2005-05-19 Thread Mike Hall
Great recommendation, thanks.-MHOn May 18, 2005, at 8:12 PM, Lee Cullens wrote:Mike,You may not be looking for a commercial IDE, but I am very happy with  WingIDE and using it with Tiger.Lee COn May 18, 2005, at 6:54 PM, Mike Hall wrote: I should of specified that I'm looking for an IDE with fullde

Re: [Tutor] Whle Loop to run again.

2005-05-19 Thread Ricardo Catalinas Jimenez
0n Thu, May 19, 2005 at 02:50:16PM +, . , wrote: > Hi, > > I want the program to run again when i input 'run' But, It doesn't... > > thanks. > > --- > impor

[Tutor] Whle Loop to run again.

2005-05-19 Thread . ,
Hi, I want the program to run again when i input 'run' But, It doesn't... thanks. --- import random raw_input("Flip a coin!") head = 0 tail = 0 run = "" whil

[Tutor] Python debugger under Tiger?

2005-05-19 Thread Mike Hansen
> Subject: > Re: [Tutor] Python debugger under Tiger? > From: > Mike Hall <[EMAIL PROTECTED]> > Date: > Wed, 18 May 2005 15:54:18 -0700 > To: > [EMAIL PROTECTED] > > To: > [EMAIL PROTECTED] > CC: > tutor@python.org > > > I should of specified that I'm looking for an IDE with full debugging. >

Re: [Tutor] Finding word in file

2005-05-19 Thread Joseph Quigley
>What are you trying? >You could simply read through the file line by line using the string >search methods. Store the previous 2 lines then when found print the >previous two lines, the current line and then read and print the next >two lines. There are more sophisticated methods but that should

Re: [Tutor] Troubles with Python modules

2005-05-19 Thread Alberto Troiano
Hey Is there any work around to accomplish what I want? I'm asking because I'm still with the same problem Regards Alberto >From: Danny Yoo <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Troubles with Python modules >Date: Tue, 17 M

Re: [Tutor] How to convert hex representation of char? (Challenge part 8)

2005-05-19 Thread plust
Kent Johnson wrote: > One way is to paste the string into a program; when Python sees '\x14' it > creates a string of length 1: > > >>> len('\x14') > 1 > > Alternately you can use the 'string_escape' codec to convert the string: > >>> s=r'\x14' > >>> len(s) > 4 > >>> t=s.decode('string_

Re: [Tutor] How to convert hex representation of char? (Challenge part 8)

2005-05-19 Thread Kent Johnson
Pieter Lust wrote: > Alan G wrote: > > '\x14' is the actual non printable charactewrs. If it were printable > > you > > would see its printed representation, because it isn't Pyhon showsw > > you > > the hex code as an escaped character but it is the character. > > > > Thanks for the input.

Re: [Tutor] How to convert hex representation of char? (Challenge part 8)

2005-05-19 Thread Pieter Lust
Alan G wrote: > '\x14' is the actual non printable charactewrs. If it were printable > you > would see its printed representation, because it isn't Pyhon showsw > you > the hex code as an escaped character but it is the character. > Thanks for the input. I'm sorry, my question was not clear