Re: [Tutor] array and dictionary

2008-09-20 Thread Shantanoo Mahajan (शंत नू महा जन)
Straight forward method would be... >>> a=[[1],[2]] >>> b={} >>> for x in range(len(a)): ... b[x] = a[x] ... >>> a [[1], [2]] >>> b {0: [1], 1: [2]} >>> regards, shantanoo On 21-Sep-08, at 11:36 AM, Dinesh B Vadhia wrote: Hi! Say, I've got a numpy array/matrix of the form: [[1 6 1 2 3]

[Tutor] array and dictionary

2008-09-20 Thread Dinesh B Vadhia
Hi! Say, I've got a numpy array/matrix of the form: [[1 6 1 2 3] [4 5 4 7 0] [2 0 8 0 2] [8 2 6 3 0] [0 7 0 3 5] [8 0 3 0 6] [8 0 0 2 2] [3 1 0 4 0] [5 0 8 0 0] [2 1 0 5 6]] And, I want to create a dictionary of rows (as the keys) mapped to lists of non-zero numbers in that row ie. di

Re: [Tutor] a simple keyboard art,,, gone wrong!

2008-09-20 Thread Alan Gauld
"Johnny" <[EMAIL PROTECTED]> wrote I was trying to get this keyboard art to work in Idle Remember that keyboard (aka ASCII) art relies on a monospaced font. Which font are you using to compose? And which in the shell window? HTH, Alan G ___

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Alan Gauld
"Wayne Watson" <[EMAIL PROTECTED]> wrote Signature.htmlThanks. Still much to learn. Where is your tutorial? see the .sig... -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - T

Re: [Tutor] Web programming advice

2008-09-20 Thread Chris Calloway
On Sep 20, 2008, at 7:51 AM, Jan Ulrich Hasecke wrote: Am 20.09.2008 um 00:01 schrieb Alan Gauld: "Patrick" <[EMAIL PROTECTED]> wrote is of paramount importance. It appears to me that Django is an all- in-one monolithic application. Years ago Zope was the number 1 and now it's basically gon

Re: [Tutor] __init__ arguments storage

2008-09-20 Thread Rob Kirkpatrick
Thanks Kent! That really makes it clear now. The bug I ran into was a while back and I've since ignored it to the point of forgetting how to invoke it, but I remember the stack trace said something about "variable received multiple arguments". I wanted to check the arguments to see if the same v

[Tutor] a simple keyboard art,,, gone wrong!

2008-09-20 Thread Johnny
I am a beginner programmer. I was trying to get this keyboard art to work in Idle I created it in Script mode, and it looks perfect. When I "copy & paste" it to try it in interactive mode, it is all scrabbled. See below for the mess up view. It suspose to say simply, "Game Over" print \

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Title: Signature.html Thanks. Still much to learn. Where is your tutorial? Alan Gauld wrote: "Wayne Watson" <[EMAIL PROTECTED]> wrote tried it, but, once the program ends (or dies?), the DOS-like window disappears. How does one prevent that? Another newbie gotcha! :-) You'll find a

Re: [Tutor] __init__ arguments storage

2008-09-20 Thread Kent Johnson
On Sat, Sep 20, 2008 at 1:32 PM, Rob Kirkpatrick <[EMAIL PROTECTED]> wrote: > Hi All, > > In between an object's creation and call to __init__, where are the __init__ > arguments stored? Is there a class dictionary that init uses to initialize > the instance? I tried printing Class.__init__, but

Re: [Tutor] Exiting a PyGTK main loop

2008-09-20 Thread Chris Fuller
Defer the quit until the mainloop is running again. something like self.connect('event-after', gtk.main_quit) Cheers On Friday 19 September 2008 17:16, Bart Cramer wrote: > Dear all, > > I am a bit stuck in a small project, trying to quit a PyGTK program. > Here are some relevant snippets: > >

Re: [Tutor] __init__ arguments storage

2008-09-20 Thread Alan Gauld
"Rob Kirkpatrick" <[EMAIL PROTECTED]> wrote In between an object's creation and call to __init__, where are the __init__ arguments stored? Is there a class dictionary that init uses to initialize the instance? I tried printing Class.__init__, but they aren't in there. I haven't checked Py

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Alan Gauld
"Wayne Watson" <[EMAIL PROTECTED]> wrote tried it, but, once the program ends (or dies?), the DOS-like window disappears. How does one prevent that? Another newbie gotcha! :-) You'll find a more detailed discussion within my Add some Style topic in my tutorial, but the simplest answer is

[Tutor] __init__ arguments storage

2008-09-20 Thread Rob Kirkpatrick
Hi All, In between an object's creation and call to __init__, where are the __init__ arguments stored? Is there a class dictionary that init uses to initialize the instance? I tried printing Class.__init__, but they aren't in there. The reason I ask is that I was trying to track down a bug wher

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Title: Signature.html Ah, the +1 is to add clarity to the program. updown is either 1, or -1, or, better in this case, as +1 or -1. It's quite possible the code will be read by others eventually. I'm emphasizing the purpose of the variable by reminding the reader of its significance. Plus is as

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Title: Signature.html Going back to the idea of just running the program outside of IDLE, I just tried it, but, once the program ends (or dies?), the DOS-like window disappears. How does one prevent that? Is there some way to keep a window open with all that has been entered and the results? My

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Title: Signature.html Kent Johnson wrote: On Sat, Sep 20, 2008 at 7:26 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: I do not think I've made an inaccurate observation. Is it possible the IDLE shell is leaving something behind that I can't see? Maybe I had two shell window up at t

Re: [Tutor] pexpect

2008-09-20 Thread Steve Poe
James, I've not used pexpect, but I've done this on a Cisco switch. I found using time.sleep and read_until of the telnet class to be helpful. 10 tn = telnetlib.Telnet('') 11 #tn.set_debuglevel(9) 12 tn.read_until('Username: \xff', 5) 13 time.sleep(10) 14 tn.write('\

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Title: Signature.html Alan Gauld wrote: "Wayne Watson" <[EMAIL PROTECTED]> wrote I do not think I've made an inaccurate observation. Is it possible the IDLE shell is leaving something behind that I can't see? That's very possible. The interpreter will remember its previous state for as

[Tutor] pexpect

2008-09-20 Thread James
Folks, Does anyone here have experience with pexpect? I'm trying to write a pexpect script which will log into a network device, gather statistics, and then dump the raw output into a file (or a string so that I can manipulate it). I'm not having much luck. Because the connection is telnet I was

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Alan Gauld
"Wayne Watson" <[EMAIL PROTECTED]> wrote I do not think I've made an inaccurate observation. Is it possible the IDLE shell is leaving something behind that I can't see? That's very possible. The interpreter will remember its previous state for as long as its running so if you import your m

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Kent Johnson
On Sat, Sep 20, 2008 at 7:26 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: > I do not think I've made an inaccurate observation. Is it possible the IDLE > shell is leaving something behind that I can't see? Maybe I had two shell > window up at the same time between the real and debug program. I'm n

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Alan Gauld
Not really the code has an error so it could not have worked. updown = +1 Is this meant to be updown += 1 maybe? Although as the error message shows you need to set it to a valid value before incrementing it, so mayber you just meant updown = 1 # no need for the + sign while keyop <>

Re: [Tutor] Web programming advice

2008-09-20 Thread Jan Ulrich Hasecke
Am 20.09.2008 um 00:01 schrieb Alan Gauld: "Patrick" <[EMAIL PROTECTED]> wrote is of paramount importance. It appears to me that Django is an all- in-one monolithic application. Years ago Zope was the number 1 and now it's basically gone. Zope is still around but it has retreated into so

[Tutor] AUTO: James D Mcclatchey is out of the office. (returning 09/29/2008)

2008-09-20 Thread James D Mcclatchey
I am out of the office until 09/29/2008. I will respond to your message when I return. Note: This is an automated response to your message "Tutor Digest, Vol 55, Issue 63" sent on 9/20/08 3:00:29. This is the only notification you will receive while this person is away. *IMPORTANT NOTICE: T

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Wayne Watson
Yes, I read it and tried the global statement with the same results, and tried it without the keyop set. It gave a prompt, and died as before.   Now I've inserted the global statement in the function and it  works by print out the value of updown inside the function.  Beats me. (read below) I

Re: [Tutor] Local Unbound Mystery

2008-09-20 Thread Sander Sweers
On Sat, Sep 20, 2008 at 00:23, Wayne Watson <[EMAIL PROTECTED]> wrote: > Well, it made a difference, and now program and output are in agreement. Not really the code has an error so it could not have worked. > updown = +1 > while keyop <> 0: You forgot to create keyop in this example. > Unbound