Re: [Tutor] Python and ICQ??
try pyICQ-t, (it's an ICQ transport for jabber implemented in python) http://pyicq-t.blathersource.org/ regards, tanja On 4/28/05, Mark Kels [EMAIL PROTECTED] wrote: Hi list ! Does anyone here knows of a way to connect to ICQ with Python? Thanks in advance. -- 1. The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. 2. Unix is user friendly - it's just picky about it's friends. 3. Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing. - Dick Brandon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- www.klaustrofobik.org ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] input()
Hello and thanks in advance. I am trying to prompt the user for some input. I need three values from the user so,I used input() like so; Matrix = input(Matrix=) error=input(error=) alpha= input(alpha=) using Macpython it works fine but when I use a terminal all I get is a blank line. When I try to enter at the command line I get this Matrix=error=alpha= Also I need to redirect any output from the program into another file, which is why I used the terminal in the first place. So, I guess I have two problems 1. How do I redirect output using Macpython? 2. How do I use input() while using a terminal? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] input()
Hi! I don't have a Mac and so I don't know Macpython. on Fri, 29 Apr 2005 07:55:20 -0500 Servando Garcia [EMAIL PROTECTED] wrote : - Servando Garcia Hello and thanks in advance. Servando GarciaI am trying to prompt the user for some input. I need three values Servando Garcia from the user so,I used input() like so; Servando Garcia Matrix = input(Matrix=) Servando Garcia error=input(error=) Servando Garcia alpha= input(alpha=) Servando Garciausing Macpython it works fine but when I use a terminal all I get is Servando Garcia a blank line. When I try to enter at the command line I get this Servando Garcia Matrix=error=alpha= Here on my sun i get the following: a=input(hello=) hello=5+6 a 11 When calling help on input the result is the following: help(input) Help on built-in function input: input(...) input([prompt]) - value Equivalent to eval(raw_input(prompt)). So the inputvalue is evaluated in python. Using raw_input() gives back the entered value: a=raw_input(hello=) hello=myInput a 'myInput' Perhaps this work's also on a Mac Servando Garcia Also I need to redirect any output from the program into another file, Servando Garcia which is why I used the terminal in the first place. So, I guess I have Servando Garcia two problems On a UNIX-Shell two programms are connected via the | - Pipe. The first one writes to stdout ( sys.stdout or print ) and the second reads from stdin Servando Garcia1. How do I redirect output using Macpython? Servando Garcia2. How do I use input() while using a terminal? Servando Garcia Servando Garcia ___ Servando Garcia Tutor maillist - Tutor@python.org Servando Garcia http://mail.python.org/mailman/listinfo/tutor Servando Garcia --- end -- HTH Ewald ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and ICQ??
On 4/29/05, tanja pislar [EMAIL PROTECTED] wrote: try pyICQ-t, (it's an ICQ transport for jabber implemented in python) http://pyicq-t.blathersource.org/ regards, tanja Thanks, but its to complicated for my needs. What I need is a simple module that will allow me to connect to ICQ and send some messages to users. -- 1. The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. 2. Unix is user friendly - it's just picky about it's friends. 3. Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing. - Dick Brandon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] cPickle (Joseph Q.)
Hi all, How could I have the user name his file? I learned that I type file_name = foo.bar How could I make it that the use could name it hello.hi? Thanks, Joe ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Re Help with this script
Hi Alan, I did not receive personally your last email but I have read it on the forum. OK i understand now what you were talking about, sorry it took such a long time for me to see the solution, the good thing about it is that I am learning tons. I will probably post soon again once I hit a wall on my next exercise. Thanks a million for your help (also Kent and John - I will try to rewrite your poem/exercise once I get a minute, thanks) Regards JC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Issue with Entry/GUI/PIL
Please ignore the rest of the code, except for the highlighted part (or the line 'ent1=Entry(topf, width=25)' to line 'ent1.insert(INSERT, wrong, if you cannot see the color). You can copy this into Python and make sure you have the GIF file in the same dir. Also, make sure that you have PIL installed. The only radio button that currently works is Alabama. I cannot get this to work. I get an error after running it after selecting Take the quiz for Alabama,and what I'm trying to do it to evaluate what the person enters in the box for the capital of Alabama. I want the user to enter the capital and if it's not right, I want the program to tell them within that box. Apparently, Python does not like the 0.0 entry within the box. The errorin Python is Exception in Tkinter callbackTraceback (most recent call last): File C:\Python24\lib\lib-tk\Tkinter.py, line 1345, in __call__ return self.func(*args) File C:\Documents and Settings\Student\Desktop\map- test.py, line 98, in stateget ent1.delete(0.0, END) File C:\Python24\lib\lib-tk\Tkinter.py, line 2307, in delete self.tk.call(self._w, 'delete', first, last)TclError: bad entry index 0.0 Why is this not working? Here's the code: from Tkinter import *import ImageTkclass Gui(Frame):def lab(self):# A generic text label for the frameself.lab1 = Label(base, text = Text for label) #text will be reset later self.lab1.grid(columnspan=3)def but(self):# A generic button for the frameself.but1 = Button(bottom, text=Take the quiz) #text and command to be set laterself.but1.pack(side=RIGHT) def labR(self):# A generic text label for the right frameself.lab1R = Label(R, text = Text for label) #text will be reset laterself.lab1R.pack(side = TOP)#def butL(self): # A generic button for the left frame#self.but1L = Button(L, text=text on button) #text and command to be set later#self.but1L.pack(side = LEFT)def butR(self):# A generic button for the right frame self.but1R = Button(RB, text=text on button) #text and command to be set laterself.but1R.pack(side = LEFT)#def entcap(None):# A generic text entry for the left frame#self.entcap1 = Entry(width=25) #width can be changed later #self.entcap1.pack(side = BOTTOM)def entR(self):# A generic text entry for the right frameent1R = Entry(RB, width=20) #width can be changed laterent1R.pack(side = TOP)def txtL(self): # A generic text box for the left frameself.txt1L = Text(L, width=100, height=5, wrap=WORD)self.txt1L.pack(side = BOTTOM)def txtR(self):# A generic text box for the right frameself.txt1R = Text(R, width=100, height=5, wrap=WORD, padx=5, pady=5)self.txt1R.pack(side = TOP)def rdbut(self):self.states = StringVar()Radiobutton(base, text=Alabama, variable=self.states , value=AL).grid(row=20, column=0, sticky=W)Radiobutton(base, text=Arkansas, variable=self.states, value=AK).grid(row=20, column=1, sticky=W)Radiobutton(base, text=Florida, variable= self.states, value=FL).grid(row=20, column=2, sticky=W)Radiobutton(base, text=Georgia, variable=self.states, value=GA).grid(row=25, column=0, sticky=W)Radiobutton(base, text=Kentucky, variable= self.states, value=KY).grid(row=25, column=1, sticky=W)Radiobutton(base, text=Louisiana, variable=self.states, value=LA).grid(row=25, column=2, sticky=W)Radiobutton(base, text=Mississippi, variable= self.states, value=MS).grid(row=30, column=0, sticky=W)Radiobutton(base, text=North Carolina, variable=self.states, value=NC).grid(row=30, column=1, sticky=W)Radiobutton(base, text=South Carolina, variable= self.states, value=SC).grid(row=30, column=2, sticky=W)Radiobutton(base, text=Tennessee, variable=self.states, value=TN).grid(row=35, column=0, sticky=W)Radiobutton(base, text=Virginia, variable= self.states, value=VA).grid(row=35, column=1, sticky=W)Radiobutton(base, text=West Virginia, variable=self.states, value=WV).grid(row=35, column=2, sticky=W) def stateget(self):state = self.states.get()if state == AL:top = Toplevel()top.title(Alabama Capital Quiz) topf = Frame(top)topf.pack()topb = Frame(top)topb.pack()pct = ImageTk.PhotoImage(file=AL.gif) var = Canvas(topb, height=250, width=250)img = var.create_image(10, 10, anchor=N, image=pct)var.pack()#top.geometry(500x500) # Now I add a text box#txtbx2 = Text(topf, height=5, width=40, bg=yellow, wrap=WORD)#txtbx2.pack(side=TOP)#txtbx2.insert(INSERT, message2)close = Button(topb, text=Close, command= top.destroy)close.pack(side=RIGHT)ent1=Entry(topf, width=25)ent1.insert(INSERT, What is the capital of Alabama?) ent1.pack()name = ent1.get()right = Correct!!!wrong = No, please try again.if name == montgomery: ent1.delete(0.0, END)ent1.insert(INSERT, right)else:ent1.delete(0.0, END)ent1.insert(INSERT, wrong) root = Tk()root.title(US Southeast Regional Quiz)gui = Gui(root)base = Frame(root)base.grid()gui.lab()gui.lab1.configure(text=Welcome to the Southeast US State Quiz!) # I will bring in another label explaining what I wantgui.lab()gui.lab1[text]=Please select a state to begin and click on the 'Take the quiz' button below.# Now for the radiobuttons
Re: [Tutor] cPickle (Joseph Q.)
On Apr 29, 2005, at 04:48, Joseph Quigley wrote: Hi all, How could I have the user name his file? I learned that I type file_name = foo.bar How could I make it that the use could name it hello.hi? Thanks, Joe Well, all you have to do is have the user input a string, and use this string as the name of the file. The raw_input function should allow you to do that. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Fwd: [Tutor] cPickle (Joseph Q.)
Begin forwarded message: From: Joseph Quigley [EMAIL PROTECTED] Date: April 29, 2005 17:16:22 BST To: Max Noel [EMAIL PROTECTED] Subject: Re: [Tutor] cPickle (Joseph Q.) I tried that and it doesn't work! I type the name and it just sits there! Here's the code: # variables name = JOTEX versn = 0.1 # end variables print name + versn def intro(): print JOTEX is a very simple command based text editor with a maximum of 6 lines (counting up though). Similar to early version of TEX. def commands(): print \nThe following commands are: \jn$ for a new line. Ex: Hello!\jn$ then Hi again! returns: Hello! Hi again! \jq$ for quiting the program at any prompt. \js$ for saving (feature not currently available) No more commands. main() def l6(): l6 = raw_input() print print save() main() def l5(): l5 = raw_input() l6() def l4(): l4 = raw_input() l5() def l3(): l3 = raw_input() l4() def l2(): l2 = raw_input() l3() def l1(): l1 = raw_input() l2() def main(): intro() print \nYou may want to see the commands. Type \jhc for commands.\nPress\ 'Enter' (Return) to begin a document prompt = raw_input( ) if \jhc$ in prompt: commands() elif \jq$ in prompt: raise SystemExit else: print \n\n\n l1() def save(): import cPickle as p file_name = test.txt f = file(file_name, 'w') all = [l1(), l2(), l3(), l4(), l5(), l6()] p.dump(all, f) f.close() main() main() At 09:44 AM 4/29/2005, you wrote: On Apr 29, 2005, at 04:48, Joseph Quigley wrote: Hi all, How could I have the user name his file? I learned that I type file_name = foo.bar How could I make it that the use could name it hello.hi? Thanks, Joe Well, all you have to do is have the user input a string, and use this string as the name of the file. The raw_input function should allow you to do that. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? -- maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: input()
On Friday, Apr 29, 2005, at 09:48 America/Chicago, [EMAIL PROTECTED] wrote: Hello and thanks in advance. I am trying to prompt the user for some input. I need three values from the user so,I used input() like so; Matrix = input(Matrix=) error=input(error=) alpha= input(alpha=) using Macpython it works fine but when I use a terminal all I get is a blank line. When I try to enter at the command line I get this Matrix=error=alpha= Also I need to redirect any output from the program into another file, which is why I used the terminal in the first place. So, I guess I have two problems 1. How do I redirect output using Macpython? 2. How do I use input() while using a terminal? It seems to work fine here for me, but I'm not sure what you are trying to do. I'm using Python 2.4 under OS 10.2.8. Perhaps you could paste a copy of the terminal prompts as they appear? Here is what my session looked like when I entered 12 and 4 for two inputs: ### csmith% cat go.py a=input('a=') b=input('b=') print a,b csmith% python go.py a=12 b=4 12 4 ### If I make a file and feed it to the program rather than entering the text by hand I get: ### csmith% cat dat 12 4 ^C csmith% python go.py dat a=b=12 4 ### If I try to redirect this to a file I get: ### csmith% python go.py dat out csmith% cat out a=b=12 4 ### One thing you might try is to change your prompt from something like a= to a=\n Which of the above scenarios are you trying to work with and what do you want the result to be? It looks like the input to input() is not echoed so you should do that yourself if you want the values the user entered to be displayed in the file/output. e.g. ### csmith% cat go2.py def echoInput(prompt=): ret = input(prompt) print ret return ret a=echoInput('a=') b=echoInput('b=') print a,b csmith% python go2.py dat out csmith% cat out a=12 b=4 12 4 ### /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] tokenize row numbering
I got over my intimidation with tokenize and learned to use it to strip comments from code files. In the process, I learned that the tuples that it returns for the position in the code of various tokens is 1-based in the row rather than 0-based, so the tuple pair (3,1),(3,2) would be the start and stop position of the = OP in the following code: ### # line 1 according to tokenize tuple # line 2 a=b #line 3 ### Does anyone have an idea of *why* the rows/physical lines of code beginning their count at 1 instead of 0? In order to process the code I either have to subtract 1 from all the first elements of tuple positions or else insert a blank line at the beginning of the list that I make out of my code when I want to process it. Is this a candidate for a feature change request? /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] enumerate offset?
Does anybody else ever run into the case of using enumerate on a slice but then wish that the original list indices were being returned instead of the ones starting at zero? I would like to see an offset argument that could be used with enumerate: ### l=range(5) for i,li in enumerate(l[3:]): print i, li def myenumerate(l,offset=0): for i,li in enumerate(l): yield i+offset, li print for i,li in myenumerate(l[3:],3): print i,li ### '''--the output-- 0 3 1 4 3 3 4 4 --end output--''' /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor