Re: [Tutor] strings and int()

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:14 AM, Mr Gerard Kelly wrote: > If you have a string "6", and you do int("6"), you get the number 6. > > But if you have a string "2*3" and you do int("2*3") you get a name error. > > How do you take an expression in a string, and evaluate the expression > to get a number

Re: [Tutor] NLTK

2009-01-15 Thread Senthil Kumaran
> Ishan Puri wrote: > Hi, > I have download NLTK for Python 2.5. It download automatically to > C:\Program Files\Python25\libs\site-packages\nltk. When I try to open a > module in python, it says that no such module exists. What do I need to do? There are ways to install the module in the si

Re: [Tutor] eval and floating point

2009-01-15 Thread Senthil Kumaran
On Thu, Jan 15, 2009 at 9:42 AM, Bill Campbell wrote: > Python does the Right Thing(tm) when dividing two integers, > returning an integer result. > Unless it is python 3k, in which integer division (single /) can result in float. Because int is a long by default. :-) -- Senthil __

Re: [Tutor] traceback

2009-01-15 Thread spir
Le Wed, 14 Jan 2009 21:19:11 +0100, Willi Richert a écrit : > Hi, > > do you observe the same behavior with traceback.format_exc()? I've used that > always in such situations which worked all the time. > > Regards, > wr Actually yes, for the traceback object returned by sys.exc_info() is None

[Tutor] single key ordered sequence

2009-01-15 Thread spir
Hello, a little algorithmic question. I have a list of tuples element, in which the first item is a kind of key. I need a target list with only one tuple per key. But the order must be kept -- so that I cannot use a temp dictionary. Additionally, in this case the chosen element for a repeted ke

Re: [Tutor] traceback

2009-01-15 Thread Willi Richert
Hi, from http://effbot.org/pyref/sys.exc_info.htm: "The information returned is specific both to the current thread and to the current stack frame. If the current stack frame is not handling an exception, the information is taken from the calling stack frame, or its caller, and so on until a s

Re: [Tutor] tkinter canvas

2009-01-15 Thread Alan Gauld
"Mr Gerard Kelly" wrote All it does take a number (6 in this case) and draw that number of blue boxes on a canvas. I want to be able to bind these boxes to an event - so that I can either click on them, or hold the mouse cursor over them, and have them change color. I don;t think you can

Re: [Tutor] eval and floating point

2009-01-15 Thread Alan Gauld
"Mr Gerard Kelly" wrote I've noticed that the eval() function gives an integer, so eval("3/2") gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a floating point number back with eval()? Move the float inside the eval: eval("float(3/2)") It's nothing to do with eval b

Re: [Tutor] Non-blocking non-interactive graphics display

2009-01-15 Thread Alan Gauld
"David Williams" wrote I am looking for the simplest way of displaying a little positional data as a line graphic in a window as a script runs. I got a bit lost in the description which followed but a couple of things stood out: My problem is that using tkinter, it looks to be a bit dif

Re: [Tutor] running & debugging in python interactive shell

2009-01-15 Thread Alan Gauld
"Artie Ziff" wrote running python scripts. Does anyone know of an article that describes best practices for running and debugging scripts inside the python shell? Of course, I use import directive to run my script for first run. I am seeking techniques for invoking parts of script after ini

Re: [Tutor] Creating simple windows in XP

2009-01-15 Thread Alan Gauld
"Alex Krycek" wrote I'd like to create very simple GUI's in XP. For the sake of simplicity, I'm trying to avoid downloading and installing anything (although I am considering EasyGui). The basic GUI framework in Python is Tkinter and that works fine on XP. See my tutorial topic on GUI prog

Re: [Tutor] eval and floating point

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:08 PM, Alan Gauld wrote: > > "Mr Gerard Kelly" wrote > >> I've noticed that the eval() function gives an integer, so eval("3/2") >> gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a >> floating point number back with eval()? > > Move the float insid

Re: [Tutor] tkinter canvas

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 12:41 AM, Mr Gerard Kelly wrote: > I want to be able to bind these boxes to an event - so that I can either > click on them, or hold the mouse cursor over them, and have them change > color. Here is a version of your program that binds the Enter and Leave events to each b

Re: [Tutor] Non-blocking non-interactive graphics display

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 1:00 AM, David Williams wrote: > I am looking for the simplest way of displaying a little positional > data as a line graphic in a window as a script runs. > > Something like: > >#Set up some points >pt1 = (0,0) >pt2 = (2,1) >pt3 = (3,2) >

Re: [Tutor] Creating simple windows in XP

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 1:29 AM, Alex Krycek wrote: > Hello, > > I'd like to create very simple GUI's in XP. For the sake of simplicity, I'm > trying to avoid downloading and installing anything (although I am > considering EasyGui). To see how well it works, I've tried having my > program run a

Re: [Tutor] traceback -- how it works?

2009-01-15 Thread spir
Le Wed, 14 Jan 2009 21:19:11 +0100, Willi Richert a écrit : > Hi, > > do you observe the same behavior with traceback.format_exc()? I've used that > always in such situations which worked all the time. > > Regards, > wr Hello again, Willi & all, I guess I got the point. I thought that traceb

Re: [Tutor] traceback

2009-01-15 Thread Kent Johnson
On Wed, Jan 14, 2009 at 12:09 PM, spir wrote: > Hello, > > I rather often use exceptions as information providers at design or debug > time. A typical use > of mine is to have a test version of methods that wrap standard version: > > def run(): >do stuff >that may >raise e

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 6:48 AM, spir wrote: > I have a list of tuples element, in which the first item is a kind of key. I > need a target list > with only one tuple per key. But the order must be kept -- so that I cannot > use a temp dictionary. > Additionally, in this case the chosen element

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Brian van den Broek
Alan Gauld said unto the world at 14/01/09 07:34 PM: "Brian van den Broek" wrote icon for Idle launching as expected. When run from IDLE, `print sys.executable' yields `C:\\Python26\\pythonw.exe'. He reports that C:\Python26 contains both python.exe and pythonw.exe. I've had him add the tex

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Brian van den Broek
Brian van den Broek said unto the world at 15/01/09 11:27 AM: Alan Gauld said unto the world at 14/01/09 07:34 PM: "Brian van den Broek" wrote DOS prompt and replies including Alan's suggestion to get a text file dump of environment variables.> With the full path, python loads as expecte

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 11:48 AM, Brian van den Broek wrote: > The (recognized by me as) relevant bits of output are: > Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program > Files\texlive\2008\bin\win32;C:\Python26 > PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH > >

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Dj Gilcrease
if he just needs to run python scripts you just need to type the script name (preferably from the directory it is in) eg: C:\Path\To\App>app_name.py and it will run Also if you have changed the enviromental variables, you need to close the command prompt and re-open it on windows since it does n

Re: [Tutor] Python3.0 and Tkinter on ubuntu 8.10 HOWTO

2009-01-15 Thread Senthil Kumaran
On Wed, Jan 14, 2009 at 03:38:20PM -0500, Vern Ceder wrote: > Since there was some interest in the question of how to get a full > Python 3.0, including Tkinter and IDLE, compiled on Ubuntu Intrepid > 8.10, I've written up what I've done and posted it at > http://learnpython.wordpress.com/200

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Marc Tompkins
On Thu, Jan 15, 2009 at 9:35 AM, Dj Gilcrease wrote: > if he just needs to run python scripts you just need to type the > script name (preferably from the directory it is in) > > eg: C:\Path\To\App>app_name.py > > and it will run > By default, and on most people's machines, not true. You can do

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Senthil Kumaran
> Also, how to practically walk in reverse order in a list without > copying it (e.g. items[::-1]), > especially if i need both indexes and items (couldn't find with > enumerate()). > Are you looking for reversed()? The way you are doing it is probably OK. But it can be simplified thus: keys = [

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Marc Tompkins
On Thu, Jan 15, 2009 at 8:48 AM, Brian van den Broek wrote: > > The (recognized by me as) relevant bits of output are: > Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program > Files\texlive\2008\bin\win32;C:\Python26 > PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH > >

Re: [Tutor] eval and floating point

2009-01-15 Thread Alan Gauld
"Andre Engels" wrote eval("float(3/2)") That still does not work, because the 'float' comes after the division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work, you'll have to put the float inside the division: eval("float(3)/2") Ahem! Quite. That was what I actually intended to p

Re: [Tutor] running & debugging in python interactive shel

2009-01-15 Thread W W
On Wed, Jan 14, 2009 at 8:18 PM, Che M wrote: > > I'd like to add to this question and expand it: can anyone point me to > a good resource on debugging *generally*? > The first result on "Debugger tutorial" on google sent me to this: http://www.cs.princeton.edu/~benjasik/gdb/gdbtut.html Thou

Re: [Tutor] eval and floating point

2009-01-15 Thread wesley chun
>>> eval("float(3/2)") >> >> That still does not work, because the 'float' comes after the >> division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work, >> you'll have to put the float inside the division: >> eval("float(3)/2") correct. as long as one of the operands is a float, the divisi

Re: [Tutor] tkinter canvas

2009-01-15 Thread Alan Gauld
"Kent Johnson" wrote for i in range(numboxes): box[i]=w.create_rectangle((1+i)*40, 40, (2+i)*40, height-40, fill="blue") w.tag_bind(box[i], '', lambda e, i=i: enter(e, i)) w.tag_bind(box[i], '', lambda e, i=i: leave(e, i)) I'm wrong again. I've never noticed tag_bind() before. Alth

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Alan Gauld
"Brian van den Broek" wrote The (recognized by me as) relevant bits of output are: Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\texlive\2008\bin\win32;C:\Python26 PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH That looks OK. Puzzling! Scraping th

Re: [Tutor] Creating simple windows in XP

2009-01-15 Thread Alex Krycek
Thanks for the suggestions guys. I had looked at Tkinter before and liked that it comes w/ Python. It's just that it's so complex writing anything. EasyGui is pretty simple, but I relying on standard tools. I liked how in VB, for example, to open a dialog box you could write: MsgBox("Text", vbOKOn

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 4:56 AM, Senthil Kumaran wrote: > > Also, how to practically walk in reverse order in a list without > > copying it (e.g. items[::-1]), > > especially if i need both indexes and items (couldn't find with > > enumerate()). > > > Are you looking for reversed()? > The way you

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Kent Johnson
On Thu, Jan 15, 2009 at 3:44 PM, Jervis Whitley wrote: > how about this: > items = [(1,'a'),(1,'b'),(2,'a'),(3,'a'), > (3,'b'),(4,'a'),(5,'a'),(5,'b'),(5,'c')] > mydict = dict(items) > items = [item for item in mydict.iteritems()] That only coincidentally preserves order; the order of

[Tutor] traceback again: __traceback__ arg for exceptions in py3.0

2009-01-15 Thread spir
I just discovered the following: PEP 3134: Exception objects now store their traceback as the __traceback__ attribute. This means that an exception object now contains all the information pertaining to an exception, and there are fewer reasons to use sys.exc_info() (though the latter is not rem

Re: [Tutor] indented grammar parsing

2009-01-15 Thread Kent Johnson
On Sun, Jan 11, 2009 at 1:11 PM, spir wrote: > Hello, > > this is a rather specific question about parsing an indented grammar. > I have a working implementation (presented below) that may be worth a critic > review -- if you like > it. > > First issue is: is there a way to express an indented fo

Re: [Tutor] Opsware Global Shell Scripting

2009-01-15 Thread Kayvan Sarikhani
Hello...thanks to several individuals, I've been able to get a little farther in this Opsware global shell script: #!/usr/bin/python import os outfile = open('test.txt','w') for servername in os.listdir('/opsw/Server/@'): print '---', servername print >> outfile, '---', servername rosh

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 9:15 AM, Kent Johnson wrote: > On Thu, Jan 15, 2009 at 3:44 PM, Jervis Whitley > wrote: > > how about this: > > items = [(1,'a'),(1,'b'),(2,'a'),(3,'a'), > > (3,'b'),(4,'a'),(5,'a'),(5,'b'),(5,'c')] > > mydict = dict(items) > > items = [item for item in mydict

Re: [Tutor] running & debugging in python interactive shel

2009-01-15 Thread Che M
Date: Thu, 15 Jan 2009 12:20:45 -0600 From: sri...@gmail.com To: pine...@hotmail.com Subject: Re: [Tutor] running & debugging in python interactive shel CC: tutor@python.org On Wed, Jan 14, 2009 at 8:18 PM, Che M wrote: >> I'd like to add to this question and expand it: can anyone poin

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Brian van den Broek
Kent Johnson said unto the world at 15/01/09 12:33 PM: On Thu, Jan 15, 2009 at 11:48 AM, Brian van den Broek wrote: The (recognized by me as) relevant bits of output are: Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\texlive\2008\bin\win32;C:\Python26 PATHEXT=.CO

Re: [Tutor] single key ordered sequence

2009-01-15 Thread bob gailer
Jervis Whitley wrote: On Fri, Jan 16, 2009 at 9:15 AM, Kent Johnson > wrote: On Thu, Jan 15, 2009 at 3:44 PM, Jervis Whitley mailto:jervi...@gmail.com>> wrote: > how about this: > items = [(1,'a'),(1,'b'),(2,'a'),(3,'a'), > (3,'b'),(4,'a'

Re: [Tutor] Creating simple windows in XP

2009-01-15 Thread Alan Gauld
"Alex Krycek" wrote EasyGui is pretty simple, but I relying on standard tools. I liked how in VB, for example, to open a dialog box you could write: MsgBox("Text", vbOKOnly, "Title"). You mean like doing import tkMessageBox tkMessageBox.showinfo("Window Text", "A short message") in Tkin

Re: [Tutor] running & debugging in python interactive shel

2009-01-15 Thread Alan Gauld
"Che M" wrote tutors here had any recommendations. I just checked Alan Gauld's tutorial and I see it doesn't have a debugger section (completely You need to get a copy of the paper book, it has a chapter on debugging, starting with print statements and going through to the Python debugger

Re: [Tutor] single key ordered sequence

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 10:39 AM, bob gailer wrote: > Jervis Whitley wrote: > >> >> >> On Fri, Jan 16, 2009 at 9:15 AM, Kent Johnson > ken...@tds.net>> wrote: >> >>On Thu, Jan 15, 2009 at 3:44 PM, Jervis Whitley >>mailto:jervi...@gmail.com>> wrote: >>> how about this: >>> items =

Re: [Tutor] help with getting python to run from command prompt onWindows XP

2009-01-15 Thread Alan Gauld
"Brian van den Broek" wrote I'll have him verify all steps again and then call `gremlins'. One last thing to try is to get him to send a screen shot with the error message showing. That will prove that he is using the right type of console, typing the right command and reporting the righ

Re: [Tutor] tkinter canvas

2009-01-15 Thread Mr Gerard Kelly
wow, that's excellent, thanks so much. I haven't got a clue how lambda functions work, but they seem pretty useful, so I'll try to figure them out. - Original Message - From: Kent Johnson Date: Thursday, January 15, 2009 10:24 pm Subject: Re: [Tutor] tkinter canvas > On Thu, Jan 15, 2009

Re: [Tutor] running & debugging in python interactive she

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 9:56 AM, Che M wrote: > > > > >> I'd like to add to this question and expand it: can anyone point me to > >> a good resource on debugging *generally*? > > The first result on "Debugger tutorial" on google sent me to this: > > > http://www.cs.princeton.edu/~benjasik/gdb/gd

[Tutor] 2 & 4 or more spaces per indentation level..

2009-01-15 Thread Eric Dorsey
Dear Pythonistas: Working in IDLE on Windows Vista, I have one program that I set to have 2 character spacing (due to the levels of if's and while's going on -- later my brother called this a bit of a code smell, ie. logic shouldn't go that deep, it should be broken out into separate functions ins

[Tutor] Corpora

2009-01-15 Thread Ishan Puri
Hi, I was wondering if anyone could tell me where I can get corpora containing IMs, or blogs or any internet communication? This is kind of urgent. Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 2 & 4 or more spaces per indentation level..

2009-01-15 Thread Senthil Kumaran
On Thu, Jan 15, 2009 at 06:57:09PM -0700, Eric Dorsey wrote: >Working in IDLE on Windows Vista, I have one program that I set to have >2 character spacing (due to the levels of if's and while's going on -- >later my brother called this a bit of a code smell, ie. logic shouldn't >go

Re: [Tutor] Corpora

2009-01-15 Thread John Fouhy
2009/1/16 Ishan Puri : > Hi, > I was wondering if anyone could tell me where I can get corpora > containing IMs, or blogs or any internet communication? This is kind of > urgent. Have you tried the enron email dataset? http://www.cs.cmu.edu/~enron/ (google may turn up other links) -- John. _

Re: [Tutor] Corpora

2009-01-15 Thread Senthil Kumaran
On Fri, Jan 16, 2009 at 9:11 AM, Ishan Puri wrote: > Hi, > I was wondering if anyone could tell me where I can get corpora > containing IMs, or blogs or any internet communication? This is kind of www.google.com And for IM's specifically, you can look at "Alice Bot" Project, the corpus will