[Tutor] Using code objects?

2005-06-20 Thread Chinook
Using code objects? === As an OO exercise I have a factory pattern that returns class objects that each have an "action" method. ClassObj.action() in turn returns a code object in my recursive process loop. I create the code objects as a one time step outside my factory pattern

Re: [Tutor] Numbers & Characters As Dictionary Keys

2005-06-20 Thread Brian van den Broek
Don Parris said unto the world upon 20/06/2005 14:10: > On Mon, 20 Jun 2005 09:11:53 +0100 > "Alan G" <[EMAIL PROTECTED]> wrote: >>for m in menu.keys(): >> print "%s\t%s" % (m,menu[m][0]) >> > > I am curious what the "%" by itself is doing. > Don Hi Don, it is indicating that the tuple

Re: [Tutor] Numbers & Characters As Dictionary Keys

2005-06-20 Thread Don Parris
On Mon, 20 Jun 2005 09:11:53 +0100 "Alan G" <[EMAIL PROTECTED]> wrote: > > "raw_input", but I get "H is not defined" when I run the script. > > Essentially, I'd like the user to enter a number for most items, > > but use letters for "Help", "Quit", and "Back to Main". > > Are you sure? That ki

Re: [Tutor] Refreshing the interpreter environment

2005-06-20 Thread Javier Ruere
lawrence wang wrote: > How do I refresh the interpreter environment without restarting it, if > possible? For example, I'm using the interpreter to test a class I'm > writing; importing and instantiating it reveals a typo; I go and fix > the typo. Now, is there any way to reload the class afresh? S

[Tutor] Refreshing the interpreter environment

2005-06-20 Thread lawrence wang
How do I refresh the interpreter environment without restarting it, if possible? For example, I'm using the interpreter to test a class I'm writing; importing and instantiating it reveals a typo; I go and fix the typo. Now, is there any way to reload the class afresh? Simply importing again doesn't

Re: [Tutor] max(len(item)) for cols

2005-06-20 Thread jfouhy
Quoting János Juhász <[EMAIL PROTECTED]>: > That I don't know is the asterisk in zip(*[labels] + rows) > I wasn't able to find in the python reference what it means. > May you help me in that ? You can find it in the language reference: http://docs.python.org/ref/calls.html Basically, suppose yo

Re: [Tutor] Calling web browser from Python

2005-06-20 Thread jfouhy
Quoting Andre Engels <[EMAIL PROTECTED]>: > Is it possible to call a web browser from Python, opening a certain > page? Preferably the user's standard web browser. Check the webbrowser module :-) -- John. ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] calling perl from python code

2005-06-20 Thread Danny Yoo
On Mon, 20 Jun 2005, Shuying Wang wrote: > Can anyone recommend a library that will let me call perl functions from > python? I have a python dictionary that I would like to convert to a > perl hash for some function. Hi Shuying, Sure! You may want to look at the PyPerl project: http://w

Re: [Tutor] Calling web browser from Python

2005-06-20 Thread Brian van den Broek
Andre Engels said unto the world upon 20/06/2005 04:26: > Is it possible to call a web browser from Python, opening a certain > page? Preferably the user's standard web browser. > > Andre Engels > ___ > Tutor maillist - Tutor@python.org > http://mail.p

[Tutor] Calling web browser from Python

2005-06-20 Thread Andre Engels
Is it possible to call a web browser from Python, opening a certain page? Preferably the user's standard web browser. Andre Engels ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Every Other

2005-06-20 Thread Alan G
JOhn, > This is probably it: > >>> arr = range(20) > >>> arr[::2] You are probably right, I forgot that slicing now had a 3rd element... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Every Other

2005-06-20 Thread Alan G
> What would be the most Pythonic way THats always going to be subjective but... > of printing (or extracting) every > other element of a list? I'd probably use range with a step of 2. for index in range(0,len(mylist),2): ptint mylist[index] Alan G Author of the Learn to Program web tuto

Re: [Tutor] Numbers & Characters As Dictionary Keys

2005-06-20 Thread Alan G
> "raw_input", but I get "H is not defined" when I run the script. > Essentially, I'd like the user to enter a number for most items, > but use letters for "Help", "Quit", and "Back to Main". Are you sure? That kind of inconsistent input is one of the big no-nos of user interface design. It us

Re: [Tutor] Layering Canvas widgets with Tkinter

2005-06-20 Thread Alan G
- def menu(y): main.grid_remove () root.update() if y ==1: menu1() etc/... def menu1(): X=Canvas(root, width=200, height=200, bg="blue") X.grid(row=0,column=0) but2=Button(X,text="back",command=mainmenu) but2.grid() def menu2():... def menu3():... root=

[Tutor] calling perl from python code

2005-06-20 Thread Shuying Wang
Hi, Can anyone recommend a library that will let me call perl functions from python? I have a python dictionary that I would like to convert to a perl hash for some function. cheers, Shuying ___ Tutor maillist - Tutor@python.org http://mail.python.org

Re: [Tutor] max(len(item)) for cols

2005-06-20 Thread János Juhász
Dear Alan, similar :) I have scripted a small sql e-mail reporting simplified from # written by Mike Brown # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 import string def TableStr(labels, rows, delim=' | '): columns = zip(*[labels] + rows) # get the maximum of ea