From pdeluca@sia.net.au Fri Jun 1 09:28:09 2001 From: pdeluca@sia.net.au (Paul De Luca) Date: Fri, 01 Jun 2001 18:28:09 +1000 Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ? Message-ID: <4.3.2.7.2.20010601175652.00adabe0@mail.sia.net.au> Hi, I was wondering if there was a FAQ for this mailing list? I have been a subscriber to this list for a few months now, and regularly see the same questions come up on the list and get answered with the same answers. Since it seems like there are a lot of newbie programmers subscribing to this list (including myself ;) it would seem like a good idea to create a FAQ or some sought of Python Resource Index with answers to questions that frequent this list, information on books available (with readers opinions) as well as links to sites that are useful and get frequently mentioned. Since this list often gets questions which are not purely about python it seems logical that a FAQ for this mailing list should exist. If one does not exist I would be willing to contribute my time. I have space on one of those free web hosts, and despite being a newbie programmer, I have been coding HTML for the past year. Any answers/comments/advice on this matter would be appreciated. ------------------------------------------- Paul De Luca Email: pdeluca@sia.net.au Ph: 0414 225561 ------------------------------------------- From GADGILP@INFOTECH.ICICI.com Fri Jun 1 09:30:28 2001 From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Fri, 1 Jun 2001 14:00:28 +0530 Subject: [Tutor] captering output of a cmd run using os.system. Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0EA75.1D3AA630 Content-Type: text/plain; charset="iso-8859-1" hello, a cmd that I run using os.sustem() gives the output that I want to assign to a var and use later in prog. How do I do that ? regards, prasad . ------_=_NextPart_001_01C0EA75.1D3AA630 Content-Type: text/html; charset="iso-8859-1" captering output of a cmd run using os.system.

hello,

a cmd that I run using os.sustem() gives the output that I want to assign to a var
and use later in prog. How do I do that ?

regards,
prasad


..

------_=_NextPart_001_01C0EA75.1D3AA630-- From karimy@nipltd.com Fri Jun 1 09:44:16 2001 From: karimy@nipltd.com (Karim Yaici) Date: Fri, 1 Jun 2001 09:44:16 +0100 Subject: [Tutor] [Fwd: [Python-Help] Dos command line] References: <3B1587FE.CCA19B58@nts-inc.com> Message-ID: <006501c0ea77$0addf4e0$a5020a0a@private.nipltd.com> Steve, I usually use popen to run DOS commands. In the following, I'll try to run a Python script and capture the output: import os script_path = "c:\\python\\mydoc\\test_popen.py" operating_system = os.name if operating_system == 'nt': # yeah! you may not need this check, but I prefer to use the 'commands' module for # *nix fd = os.popen('python %s'%script_path) outtext = fd.read() fd.close() The same thing if you want to run other commands (dir, cd...). Keep in mind that if you are running python 1.52, according to the docs, this method is unreliable(it does not seem to work on IDE's). I think this has been fixed in 2.0 (& 2.1). Last thing, if your script (test_popen.py) contains any errors then the output will be empty under Windows( correct me if I am wrong , guys:-) ) Cheers, Karim ----- Original Message ----- From: "steve tran" To: Sent: Thursday, May 31, 2001 12:53 AM Subject: [Tutor] [Fwd: [Python-Help] Dos command line] > Hi, > > Can I have an example for os.open to run dos comand line or batch file? > > thanks, > > Steve > From r.b.rigilink@chello.nl Fri Jun 1 10:03:31 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Fri, 01 Jun 2001 11:03:31 +0200 Subject: [Tutor] captering output of a cmd run using os.system. References: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3> Message-ID: <3B175A63.9EF11D10@chello.nl> > GADGIL PRASAD /INFRA/INFOTECH wrote: > > hello, > > a cmd that I run using os.sustem() gives the output that I want to > assign to a var > and use later in prog. How do I do that ? > > regards, > prasad > > .. have a look at the os.popen() family of commands. In stead of os.system('some_command') you'll want something like pipe = os.popen('some_command', 'r') The pipe is connected to the standard output of 'some_command'. It is a file-like object, so you can read from it. output = pipe.readlines() reads everything that 'some_command' would normally have written to screen and assigns it to output. You can parse this to find the values you're interested in. Have a look at he documentation for further info. PS. before Python 2.0, os.popen() worked somewhat unreliable under windows. If you use Python 1.5.2 under windows, maybe someone else canb give you additional info. Hope this helps, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From dyoo@hkn.eecs.berkeley.edu Fri Jun 1 09:54:40 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 01:54:40 -0700 (PDT) Subject: [Tutor] captering output of a cmd run using os.system. In-Reply-To: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3> Message-ID: On Fri, 1 Jun 2001, GADGIL PRASAD /INFRA/INFOTECH wrote: > a cmd that I run using os.sustem() gives the output that I want to > assign to a var and use later in prog. How do I do that ? Ah, that's where you'll want to use os.popen(). It does pretty much the same thing as os.system() --- it executes an external command from the system. The only difference is that it allows us to grab the output directly. For example, if we wanted to store the output of a 'dir' command, we can do something like this: ### # Small program to demonstrate os.popen(). import os f = os.popen('dir') output = f.read() print "Here's what we got back:", output ### What os.popen() does is return something that looks like a file: we can read() from it in one sitting, or pull out lines at a time with readline(). os.popen() is mentioned in the reference docs here: http://python.org/doc/current/lib/os-newstreams.html If you're curious, you might want to see what sort of things we'd expect files to do: http://python.org/doc/current/lib/bltin-file-objects. Good luck! From dyoo@hkn.eecs.berkeley.edu Fri Jun 1 10:03:03 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 02:03:03 -0700 (PDT) Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ? In-Reply-To: <4.3.2.7.2.20010601175652.00adabe0@mail.sia.net.au> Message-ID: On Fri, 1 Jun 2001, Paul De Luca wrote: > I was wondering if there was a FAQ for this mailing list? I have > been a subscriber to this list for a few months now, and regularly see > the same questions come up on the list and get answered with the same > answers. Since it seems like there are a lot of newbie programmers > subscribing to this This isn't off topic at all; a FAQ would be a wonderful thing for this list. We don't have a dedicated one for beginning Python programmers, but it would definitely be a great resource. Let's have it separated from the official FAQ. The official Python FAQ is good, but it's overwhelming! (It also deals with questions that beginners probably don't frequently ask in their wildest imaginations. *grin*) From ppathiyi@cisco.com Fri Jun 1 10:08:52 2001 From: ppathiyi@cisco.com (Praveen Pathiyil) Date: Fri, 1 Jun 2001 14:38:52 +0530 Subject: [Tutor] captering output of a cmd run using os.system. References: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3> Message-ID: <011901c0ea7a$7ab229a0$37ef87c0@ppathiyipc> This is a multi-part message in MIME format. ------=_NextPart_000_0116_01C0EAA8.943C9EE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable captering output of a cmd run using os.system.You can use the os.popen3 = command instead. This gives you access to the stdin, stdout and stderr of the command. std_out, std_in, std_err =3D popen2.popen3(line) resp_suc =3D std_out.readlines() resp_err =3D std_err.readlines() Where "line" will be your command. Rgds, Praveen. ----- Original Message -----=20 From: GADGIL PRASAD /INFRA/INFOTECH=20 To: 'tutor@python.org'=20 Sent: Friday, June 01, 2001 2:00 PM Subject: [Tutor] captering output of a cmd run using os.system. hello,=20 a cmd that I run using os.sustem() gives the output that I want to = assign to a var=20 and use later in prog. How do I do that ?=20 regards,=20 prasad=20 ..=20 ------=_NextPart_000_0116_01C0EAA8.943C9EE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable captering output of a cmd run using = os.system.
You can use the os.popen3 command=20 instead.
This gives you access to the stdin, = stdout and=20 stderr of the command.
 
          &nbs= p;    =20 std_out, std_in, std_err =3D=20 popen2.popen3(line)
        &n= bsp;      =20 resp_suc =3D=20 std_out.readlines()
        &n= bsp;      =20 resp_err =3D std_err.readlines()
Where "line" will be your=20 command.
 
Rgds,
Praveen.
 
----- Original Message -----
From:=20 GADGIL PRASAD /INFRA/INFOTECH =
Sent: Friday, June 01, 2001 = 2:00 PM
Subject: [Tutor] captering = output of a=20 cmd run using os.system.

hello,

a cmd that I run using os.sustem() gives the output = that I=20 want to assign to a var
and use later in = prog. How do=20 I do that ?

regards,
prasad =


..

------=_NextPart_000_0116_01C0EAA8.943C9EE0-- From GADGILP@INFOTECH.ICICI.com Fri Jun 1 10:16:54 2001 From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Fri, 1 Jun 2001 14:46:54 +0530 Subject: [Tutor] captering output of a cmd run using os.system. Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0EA7B.99B448A0 Content-Type: text/plain; charset="iso-8859-1" hi, that works! thanks daniel, roeland, lindsey. regards, prasad > -----Original Message----- > From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu] > Sent: Friday, June 01, 2001 2:25 PM > To: GADGIL PRASAD /INFRA/INFOTECH > Cc: 'tutor@python.org' > Subject: Re: [Tutor] captering output of a cmd run using os.system. > > > On Fri, 1 Jun 2001, GADGIL PRASAD /INFRA/INFOTECH wrote: > > > a cmd that I run using os.sustem() gives the output that I want to > > assign to a var and use later in prog. How do I do that ? > > Ah, that's where you'll want to use os.popen(). It does > pretty much the > same thing as os.system() --- it executes an external command from the > system. The only difference is that it allows us to grab the output > directly. > > > For example, if we wanted to store the output of a 'dir' > command, we can > do something like this: > > ### > # Small program to demonstrate os.popen(). > import os > > f = os.popen('dir') > output = f.read() > > print "Here's what we got back:", output > ### > > > What os.popen() does is return something that looks like a > file: we can > read() from it in one sitting, or pull out lines at a time with > readline(). os.popen() is mentioned in the reference docs here: > > http://python.org/doc/current/lib/os-newstreams.html > > > If you're curious, you might want to see what sort of things > we'd expect > files to do: > > http://python.org/doc/current/lib/bltin-file-objects. > > > Good luck! > . ------_=_NextPart_001_01C0EA7B.99B448A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [Tutor] captering output of a cmd run using = os.system.

hi,

that works! thanks daniel, roeland, lindsey.

regards,
prasad

> -----Original Message-----
> From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley= .edu]
> Sent: Friday, June 01, 2001 2:25 PM
> To: GADGIL PRASAD /INFRA/INFOTECH
> Cc: 'tutor@python.org'
> Subject: Re: [Tutor] captering output of a cmd = run using os.system.
>
>
> On Fri, 1 Jun 2001, GADGIL = PRASAD     /INFRA/INFOTECH wrote:
>
> > a cmd that I run using os.sustem() gives = the output that I want to
> > assign to a var and use later in prog. How = do I do that ?
>
> Ah, that's where you'll want to use = os.popen().  It does
> pretty much the
> same thing as os.system() --- it executes an = external command from the
> system.  The only difference is that it = allows us to grab the output
> directly.
>
>
> For example, if we wanted to store the output = of a 'dir'
> command, we can
> do something like this:
>
> ###
> # Small program to demonstrate = os.popen().
> import os
>
> f =3D os.popen('dir')
> output =3D f.read()
>
> print "Here's what we got back:", = output
> ###
>
>
> What os.popen() does is return something that = looks like a
> file: we can
> read() from it in one sitting, or pull out = lines at a time with
> readline().  os.popen() is mentioned in = the reference docs here:
>
>     http://python.org/doc/current/lib/os-newstreams.html
>
>
> If you're curious, you might want to see what = sort of things
> we'd expect
> files to do:
>
>    
http://python.org/doc/current/lib/bltin-file-objects.
>
>
> Good luck!
>


..

------_=_NextPart_001_01C0EA7B.99B448A0-- From dyoo@hkn.eecs.berkeley.edu Fri Jun 1 10:16:29 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 02:16:29 -0700 (PDT) Subject: [Tutor] Lists... [book recommendation] In-Reply-To: Message-ID: On Thu, 31 May 2001, Andrew Wilkins wrote: > > If it's possible to sort both lists of numbers, then taking the > > intersection of two sorted lists isn't too bad either; what kind of things > > will your lists contain? > > They'll just contain positive integers, sorry for not mentioning > earlier...I'll try to be a little less abstract in future! But it > really doesn't need to be sorted, I just want to know whether any of > list a's elements are contained in list b. The solutions I've got > already are great, so don't worry about this one anymore. Thanks! It's an interesting problem though; it almost reminds me of something I saw from the book, "Programming Pearls", by Jon Bentley. Bentley's introductory problem is similar because it deals with sorting a lot of phone numbers. His program was expected to deal with millions of numbers, so he needed to do something really cute to get it to sort quickly. Just wanted to throw that book recommendation out in the open. *grin* "Programming Pearls" is a very nice book though and a good read! From toodles@yifan.net Fri Jun 1 10:29:56 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Fri, 1 Jun 2001 17:29:56 +0800 Subject: [Tutor] captering output of a cmd run using os.system. In-Reply-To: <3B175A63.9EF11D10@chello.nl> Message-ID: Sorry to do a thread takeover here, but I'm going to anyway :o) I asked not too long ago but I don't think I got a reply, so I'll just try again. (FYI I'm using WinME, with Python 2.1) I'm not familiar with popen, and I looked through the docs and couldn't find anything, so I would like to know how this works... With popen when you pipe to a program, it doesn't bring up the stdout - it goes straight to the pipe. Is it possible for the output to be directed both to the pipe and to stdout? Let's say I have the following: pipe = os.popen('python t','r') print pipe.read() ############ t.py should look like: while 1: x=raw_input('') print x How can I get the above to come up as visible? With popen it seems to work in the background. Is it possible to also collect input from stdin as well as the pipe? Say if I wanted to send a response to the raw_input bit through the pipe, or through the actual stdin... TIA, Andrew Wilkins From NHYTRO@compuserve.com Fri Jun 1 10:30:03 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Fri, 1 Jun 2001 05:30:03 -0400 Subject: [Tutor] String puzzle... Message-ID: <200106010531_MC3-D3E6-4CB4@compuserve.com> Hi guys! This tiny bug hast stopped me releasing my online HTML Page editor for testing. I am retrieveng per python/CGI HTML code from a clients browser and storing in a databse on a remote server. The same client can edit his= and save hispages. To facilitate the bility to edit existing pages, I jus= t retrieve the content from the databse and present it in a content editor = in a browser client automatically. THE BUG ---------------------- As long as the the HTML is written with out carriage returns from the use= r, everything is fine. The carriage return or "

" tag is entered by the us= er from the browser by tapping the enter key. The editor on its part fails t= o display any text or HTML code that is not written in the same line, it complains of an "Unterminated String" error. I have stripped spaces, by database entry, and database access for writin= g, but the cgi always writes the TEXT/HTML in separte lines if he user has inputted a carriage return in the entry/edit form. THE QUESTION ----------------------------- How do I strip a a carriage return? is it really a carriage return thats tripping my code up? Sorry for rambling, but the problem was too difficult to descibe in fewer= sentences. Best regards Sharriff From alan.gauld@bt.com Fri Jun 1 10:46:40 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 10:46:40 +0100 Subject: [Tutor] starting tcl? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7E9@mbtlipnt02.btlabs.bt.co.uk> > I'm on windows 98 IE and have python 2.1 > On Alan Gaulds webpage lessons it says to type tclsh80 > at the dos prompt to start tcl. Yes, unfortunately from Python 2.0(*) they stopped shipping tcl with Python, they only include the DLLs needed to run Tkinter. From the python users point of view thats great. From my tutors point of view thats bad... I need to mention that somewhere on the site I guess... You can download the real Tcl (for free) from the tcl web link on the intro page http://www.scriptics.com Scriptics no longer exists but the url redirects to the correct site... Sorry about that, Alan G. (*)It might be from v1.6 I never used it... From alan.gauld@bt.com Fri Jun 1 10:51:04 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 10:51:04 +0100 Subject: [Tutor] Lists... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk> > Is there a way of returning the intersection of two lists? > Eg. [1,2,'3',4.0,'x'] & [1,8,'3',9,10,'x'] to return [1,'3','x'] Several ways. The easiest for me is: L1 = [1,2,'3',4.0,'x'] L2 = [1,8,'3',9,10,'x'] intersect = filter(lambda x: (x in L2), L1) The (x in L2) parens are not needed but I like to use them to clarify the extent of the lambda expression Alan G From lonetwin@yahoo.com Fri Jun 1 11:10:00 2001 From: lonetwin@yahoo.com (steve) Date: Fri, 1 Jun 2001 15:40:00 +0530 Subject: [Tutor] captering output of a cmd run using os.system. In-Reply-To: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3> References: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3> Message-ID: <01060115400002.03175@mercury.in.cqsl.com> Hey there, > > > a cmd that I run using os.sustem() gives the output that I want to > > > assign to a var and use later in prog. How do I do that ? > > A lil' bit too late in the thread , 'cos I didn't chk my mail,.....but I=20 prefer to use the commands module, commands.getoutput(),=20 commands.getstatusoutput()....stuff like that,...just thought I'd mention= =20 that, even tho' the Ques. is Ans'ed Peace Steve --=20 |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##||=09 |||/\##|||||||||##/\||=09 |/ \#########/ \=09 |\ \#######/ /=09 ||\____/#######\____/|=09 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09 Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D From dyoo@hkn.eecs.berkeley.edu Fri Jun 1 11:07:20 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 03:07:20 -0700 (PDT) Subject: [Tutor] captering output of a cmd run using os.system. In-Reply-To: Message-ID: On Fri, 1 Jun 2001, Andrew Wilkins wrote: > Let's say I have the following: > > pipe = os.popen('python t','r') > print pipe.read() > > ############ > t.py should look like: > > while 1: > x=raw_input('') > print x > > How can I get the above to come up as visible? With popen it seems to > work in the background. > Is it possible to also collect input from stdin as well as the pipe? > Say if I wanted to send a response to the raw_input bit through the > pipe, or through the actual stdin... Yes: you'll want to use the extended popen(): os.popen2(). It gives back two file-like objects, one for input, and the other for output. For reference, let's look at the documentation: """ popen2(cmd[, bufsize[, mode]]) Executes cmd as a sub-process. Returns the file objects (child_stdin, child_stdout). New in version 2.0. """ http://python.org/doc/current/lib/os-newstreams.html Warning! They switched the order of the arguments "bufsize" and "mode" between os.popen() and os.popen2(). By default, though, it's in text mode, so there's usually less of a need to tell Python to override the defaults. What we can do, then, might look something like this: ### input_pipe, output_pipe = os.popen2('python t') input_pipe.write("Hello world, this is a test.\n") print output_pipe.read() ### I have not been able to test this on Windows though, so I'm not sure how successful this will be... *grin* Try it out, and if you run into problems, email us again. Good luck! From alan.gauld@bt.com Fri Jun 1 11:01:46 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 11:01:46 +0100 Subject: [Tutor] Python syntax highligting with Vim Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EB@mbtlipnt02.btlabs.bt.co.uk> > and would like to implement it in gvim under windows. It should already work > cannot find any documentation on turning on syntax > highligting. Try :help syntax But put simply its: :syntax on Or put the line syntax on in your .gvimrc file. Alan g From alan.gauld@bt.com Fri Jun 1 11:05:27 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 11:05:27 +0100 Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EC@mbtlipnt02.btlabs.bt.co.uk> > If one does not exist I would be willing to contribute my > time. You said the magic words. Feel free, I'm pretty sure there iusn't a tutor-faq yet and yes we do get a lot of duplication. Just nobody else has time... So I say go for it. Alan G. From alan.gauld@bt.com Fri Jun 1 11:09:11 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 11:09:11 +0100 Subject: [Tutor] captering output of a cmd run using os.system. Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7ED@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0EA82.E7A76810 Content-type: text/plain; charset="ISO-8859-1" > You can use the os.popen3 command instead. You might need to use the version of popwen in the winall package if you are on NT/W9x - it seems to work better... Alan g ------_=_NextPart_001_01C0EA82.E7A76810 Content-type: text/html; charset="ISO-8859-1" captering output of a cmd run using os.system.

You can use the os.popen3 command instead. 
 
You might need to use the version of popwen in
the winall package if you are on NT/W9x
- it seems to work better...
 
Alan g
 
 
 
------_=_NextPart_001_01C0EA82.E7A76810-- From dyoo@hkn.eecs.berkeley.edu Fri Jun 1 11:18:18 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 03:18:18 -0700 (PDT) Subject: [Tutor] String puzzle... In-Reply-To: <200106010531_MC3-D3E6-4CB4@compuserve.com> Message-ID: On Fri, 1 Jun 2001, Sharriff Aina wrote: > How do I strip a a carriage return? is it really a carriage return > thats tripping my code up? Might be; we'd probably need to see the exact error message to be more sure about it. The carriage return character can be written as "\r" in Python, if you have your form output, you can do something like a replace(): ### >>> myform = '''this is a test form with some carriage\r\n returns in it.''' >>> myform = myform.replace('\r', '') ### From craig@osa.att.ne.jp Fri Jun 1 11:39:19 2001 From: craig@osa.att.ne.jp (Craig Hagerman) Date: Fri, 01 Jun 2001 19:39:19 +0900 Subject: [Tutor] bitwise operations Message-ID: Hi, Could anyone tell me all there is to know about bit manipulation; that is, how and why a person would want to be fiddling with bits. I have several books on Python (as well as some other languages) and they tell me what the bitwise operators are but don't tell me how I would use them, or in what cases such use would be benificial. Any bit guru's up to such an explainatio for me? Craig Hagerman From arcege@speakeasy.net Fri Jun 1 12:45:31 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Fri, 1 Jun 2001 07:45:31 -0400 (EDT) Subject: [Tutor] captering output of a cmd run using os.system. In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7ED@mbtlipnt02.btlabs.bt.co.uk> from "alan.gauld@bt.com" at Jun 01, 2001 11:09:11 AM Message-ID: <200106011145.f51BjVO02073@dsl092-074-184.bos1.dsl.speakeasy.net> alan.gauld@bt.com wrote > > ------_=_NextPart_001_01C0EA82.E7A76810 > Content-type: text/plain; charset="ISO-8859-1" > > > You can use the os.popen3 command instead. > > You might need to use the version of popwen in > the winall package if you are on NT/W9x > - it seems to work better... WinXX os.popen also has a bug in GUI environments and will fail anyways (which is why it doesn't work in the IDEs). One win32all solution is: >>> import win32pipe >>> file = win32pipe.popen("echo Hello from Python", "r") >>> file.read() 'Hello from Python\012' >>> There are other modules to help spawn programs this way. If you wish to do a lot of WinXX Python programming, you might want to get Hammond&Robinson's _Python Programming on Win32_. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From NHYTRO@compuserve.com Fri Jun 1 12:48:11 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Fri, 1 Jun 2001 07:48:11 -0400 Subject: [Tutor] Thanks Message-ID: <200106010748_MC3-D3EC-C6FD@compuserve.com> I would like to thank all the members of this list that helped me through= the bumpy ride of coding an online HTML editor, I hope one day to be a proficient as you all in order to help others as you have helped me. My application is still "Raw", it its far from being finished, but its something I can show my boss to underline Pythons feasibility in such a project. Best regards Sharriff From alan.gauld@bt.com Fri Jun 1 13:18:42 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 1 Jun 2001 13:18:42 +0100 Subject: [Tutor] bitwise operations Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F1@mbtlipnt02.btlabs.bt.co.uk> > Could anyone tell me all there is to know about bit > manipulation; No, I doubt it. I don'ty think anyone has figured that out yet... Some things you might like to do a search on the net for are 'Boolean Algenra' and 'Bitmasks' > why a person would want to be fiddling with bits. Bits are a compact way of storing a lot of data which is boolean by nature. For example software used for bulk processing of a long list of items might keep a note of which items have changed(and hence need reprocessing) by adding a boolean value flag to the reords - but that (a) changes the records and (b) takes up a byte per record. An altrernative solution is to store a block of memory with a single bit representing each record, then simply switch that bit on if the reord changes. The bulk processor then scans the bits and processes the records with a bit set. This scheme is what is used in practice for synchronising mirrored hard disks in large data centres etc... the bits represent the raw sectors of the disk and the OS updates the bit image after every write. > bitwise operators are but don't tell me how > I would use them, or in what cases such use > would be benificial. But there are myriad other uses for these, usually in a low level systems context and often in situations where storage space is expensive - like networking protocols etc. I'll leave explaining how to use "bit masks" to read/write individual bits within a block of storage to someone else... :-) Alan G. From shalehperry@home.com Fri Jun 1 15:14:49 2001 From: shalehperry@home.com (Sean 'Shaleh' Perry) Date: Fri, 01 Jun 2001 07:14:49 -0700 (PDT) Subject: [Tutor] String puzzle... In-Reply-To: Message-ID: >### >>>> myform = '''this is a test form > > with some carriage\r\n returns in it.''' >>>> myform = myform.replace('\r', '') >### > or simply use strip(), which will remove leading and trailing whitespace of any kind. Which, in this instance seems like the right thing to do. There is also rstrip() which only strips from the right. From BlakeW@rpmtec.com Fri Jun 1 14:53:24 2001 From: BlakeW@rpmtec.com (Blake Winton (Screaming)) Date: Fri, 1 Jun 2001 09:53:24 -0400 Subject: [Tutor] bitwise operations Message-ID: <8551136CB6F6D311811B00508B8B92E0C897C0@mail.rpmtec.com> > > Could anyone tell me all there is to know about bit > > manipulation; > No, I doubt it. I don'ty think anyone has figured > that out yet... Some things you might like to do > a search on the net for are 'Boolean Algenra' > and 'Bitmasks' Okay, but surely we could give Craig a short overview... (See the bottom of the message for descriptions of setting bits, clearing bits, and checking if bits are set.) > > why a person would want to be fiddling with bits. > Bits are a compact way of storing a lot of data which > is boolean by nature. [ some good examples snipped... ] > But there are myriad other uses for these, > usually in a low level systems context and > often in situations where storage space is > expensive - like networking protocols etc. I also saw a neat application of them in a financial application I'm looking at. Basically, you can set up Pre-Authorized Cash Transfers to happen once or twice a month, on any days you choose. As a compact (and easy?) way of representing those pieces of information, the coders chose to use an integer, as a bit mask. So, if we look at some examples of the individual bits, we can see what's going on. If you wanted the transfers to occur on the 3rd and the 7th, you would set those bits to one, and leave the rest as 0, to get: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ... 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 ... (which I've wrote backwards, so we'll flip it to be 1000100 (base 2) which equals 68 (base 10).) Or, if you only wanted stuff transfered on the 5th of each month, you you set the 5th bit to one, and the rest to 0, to get: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ... 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ... (which I've wrote backwards, so we'll flip it to be 10000 (base 2) which equals 16 (base 10).) Then, to see if a current day has any scheduled transfers, all the calling program has to do is take that day number, and check if the bit is set. > I'll leave explaining how to use "bit masks" > to read/write individual bits within a block > of storage to someone else... :-) I'll try it... First, we'll need a short course in hexadecimal numbers, because they're easier to print out. If you take a binary number, like 100100 (which equals 36), we can break the digits of it up into groups of 4, to get 10 0100, and add a couple of 0s at the front to make 4 digits, and we get 0010 0100. Now, each of these groups can be turned into a number with the following chart: 0000 = 0 1000 = 8 0001 = 1 1001 = 9 0010 = 2 1010 = A (10) 0011 = 3 1011 = B (11) 0100 = 4 1100 = C (12) 0101 = 5 1101 = D (13) 0110 = 6 1110 = E (14) 0111 = 7 1111 = F (15) These are the hexadecimal numbers. And if we look them up, we find that our number 0010 0100 turns into 24 (hex). To make it easy for us to tell the difference between 24 (decimal) and 24 (hex), we stick a "0x" onto the front of the hex number, to get "0x24". And if we start python, we can see that it works. >>> print hex(36) 0x24 So, from here on in, I'm just going to print out the hex numbers. If you want to know the binary, you can look it up... I should probably also tell you about the << operator. It takes a number, and shifts it left by another number. So, if we have 1 << 4, in binary, it makes 1 turn into 10000 (think of adding 4 0s onto the end of the number in binary). This gives us an easy way of selecting the 4th bit, just use 1<<3. (Because 1<<0 is the first bit.) Now, on to the actual stuff... To set a bit in a bit mask, you use the "or" operator, (written "|"). But then we need to assign it back to the variable we're testing. So, lets start with an x of 0, and set some bits in it. Jython 2.0 on java1.2.2 (JIT: symcjit) Type "copyright", "credits" or "license" for more information. >>> x = 0 >>> print hex(x) 0x0 >>> x = x | 1 << 4 >>> print hex(x) 0x10 >>> # in binary 0001 0000, so the 5th bit is set. >>> x = x | 1 << 2 >>> print hex(x) 0x14 >>> # in binary 0001 0100, so the 5th and 3rd bits are set. It sort of looks like we're just adding here, but if we try to set the second bit again, we get: >>> x = x | 1 << 2 >>> print hex(x) 0x14 If we want to clear a bit, it's a little more complicated. We want to use the "and" operator, written "&", but with all the bits set except for the one we want. To get that, we need the "not" operator, written "~". So, to clear the 3rd bit, we use x = x & ~(1 << 2) >>> x = x & ~(1 << 2) >>> print hex(x) 0x10 >>> # And we're back to 0001 0000, so the 5th bit is set. Finally, to test if the 5th bit is set, we again use the "and" operator ("&"), but this time, we check that the result is not equal to 0. >>> print (x & (1<<4)) != 0 1 It's probably useful to you to make three functions. def setBit( x, bitNum ): return x | 1 << bitNum def clearBit( x, bitNum ): return x & ~( 1 << bitNum ) def checkBit( x, bitNum ): return (x & (1< Actually I had tried "stripping" even on both sides, before database acce= ss and after, no difference. This worked: ## result =3D string.replace(myform,'\n', '') it was a NEWLINE that tripped me up the whole time :-)) Thanks for the tip all the same Best regards Sharriff Nachricht geschrieben von INTERNET:tutor@python.org >>### >>>> myform =3D '''this is a test form > = > with some carriage\r\n returns in it.''' >>>> myform =3D myform.replace('\r', '') >### > = or simply use strip(), which will remove leading and trailing whitespace = of any kind. Which, in this instance seems like the right thing to do. There i= s also rstrip() which only strips from the right.< From clickron@webtv.net Fri Jun 1 23:32:23 2001 From: clickron@webtv.net (clickron@webtv.net) Date: Fri, 1 Jun 2001 18:32:23 -0400 (EDT) Subject: [Tutor] starting tcl? Thanks Message-ID: <23824-3B1817F7-115@storefull-167.iap.bryant.webtv.net> Thanks for the help. As I try to learn this stuff it can be kind of confusing and frustrating, but it's coming slow but sure. Ron From lgwb@home.com Sat Jun 2 05:25:26 2001 From: lgwb@home.com (Michael Schmitt) Date: Fri, 1 Jun 2001 23:25:26 -0500 Subject: [Tutor] Lists... References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <00e901c0eb1c$0cb9aac0$0a0a0a0a@mntp1.il.home.com> Just for fun I added a function using Alan G method to the Roeland's timing code as follows: def intersect1(l1, l2): '''brute force intersection of two lists''' if len(l1) > 1000: print 'forget about it...\n brute force number invalid!' return l1 return [item for item in l1 if item in l2] def intersect2(l1, l2): '''intersection of two lists, using dicts''' dict = {} for item in l2: dict[item] = None return [item for item in l1 if dict.has_key(item)] def intersect2a(l1, l2): '''using dicts with filter, thanks to Remco Gehrlich''' dict = {} for item in l2: dict[item] = 1 return filter(dict.has_key, l1) def intersect3(l1, l2): '''intersection of two sorted lists of unique items''' result = [] lo = 0 hi = len(l2) for i in l1: for j in xrange(lo, hi): n = cmp(l2[j], i) if n==-1: lo = j elif n==1: break else: lo = j result.append(i) break return result def intersect_eas(L1, L2): '''The easiest way for Alan G''' return filter(lambda x: (x in L2), L1) def make_list(n): '''Make a sorted list of unique ints larger than 1''' import random l = [] x = 1 for i in xrange(n): x = x+random.randrange(1, 5) l.append(x) return l def time_func(intersect_func, l1, l2): import time t1 = time.time() l = intersect_func(l1, l2) t2 = time.time()-t1 # print l[0:10] return t2 def test(n): l1 = make_list(n) l2 = make_list(n) print 'Brute force (n=%i), t=%f' % (n, time_func(intersect1, l1, l2)) print 'Dict lookup (n=%i), t=%f' % (n, time_func(intersect2, l1, l2)) print 'Dict filter (n=%i), t=%f' % (n, time_func(intersect2a, l1, l2)) print 'Sorted list (n=%i), t=%f' % (n, time_func(intersect3, l1, l2)) print 'Sort easy (n=%i), t=%f' % (n, time_func(intersect_eas, l1,l2)) if __name__=='__main__': test(10) test(100) test(1000) test(10000) and the results..... Brute force (n=10), t=0.000000 Dict lookup (n=10), t=0.000000 Dict filter (n=10), t=0.000000 Sorted list (n=10), t=0.000000 Sort easy (n=10), t=0.000000 Brute force (n=100), t=0.000000 Dict lookup (n=100), t=0.010000 Dict filter (n=100), t=0.000000 Sorted list (n=100), t=0.000000 Sort easy (n=100), t=0.000000 Brute force (n=1000), t=0.631000 Dict lookup (n=1000), t=0.030000 Dict filter (n=1000), t=0.021000 Sorted list (n=1000), t=0.060000 Sort easy (n=1000), t=0.010000 forget about it... brute force number invalid! Brute force (n=10000), t=0.131000 Dict lookup (n=10000), t=0.270000 Dict filter (n=10000), t=0.210000 Sorted list (n=10000), t=0.681000 Sort easy (n=10000), t=0.210000 Thanks guys... that was cool. Question regarding running the brute force method with values of 10000 for n under IDLE, "how do I stop the code from running with out shuting down IDLE?" Michael Schmitt From dyoo@hkn.eecs.berkeley.edu Sat Jun 2 06:39:47 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 22:39:47 -0700 (PDT) Subject: [Tutor] Lists... [book recommendation for Programming Pearls] In-Reply-To: <00f101c0eb1c$724ffbf0$0a0a0a0a@mntp1.il.home.com> Message-ID: On Fri, 1 Jun 2001, Michael Schmitt wrote: > So is the book programming language independent? Will I get anything > out of it if I don't know C and only Python? It uses a bit of C, C++, and pseudocode, but the ideas are very transferable to Python. The focus of the book is conceptual. Here's part of his Preface: """The columns in this book are about a more glamorous aspect of the profession: programming pearls whose origins lie beyond solid engineering, in the realm of insight and creativity. Just as natural pearls grow from grains of sand that have irritated oysters, these programming pearls have grown from real problems that have irritated real programmers. The programs are fun, and they teach important programming techniques and fundamental design principles. Most of these essays originally appeared in my "Programming Pearls" column in Communications of the Association for Computing Machinery. They were collected, revised, and published as the first edition of this book in 1986. Twelve of the thirteen pieces in the first edition have been edited substantially for this edition, and three new columns hav ebeen added. The only backgorund the book assumes is programming experience in a high-level language. Advanced techniques (such as templates in C++) show up now and then, but the reader unfamiliar with such topics will be able to skip to the next section with impunity. Although each column may be read by itself, there is a logical grouping to the complete set. columns 1 through 5 form Part I of the book. They review programming fundamentals: problem definition, algorithms, data structures and program verification and testing. Part II is built around the theme of efficiency, which is sometimes important in itself and is always a fine springboard into interesting programming problems. Part III applies those techniques to several substantial problems in sorting, searching and strings.""" Whew! Anyway, I recommend taking a look at it in your local bookstore, and see if it's useful for you. It's one of the books I really wish someone had recommended to me years ago, so that's why I'm recommending it now. *grin* Hope this helps! From dyoo@hkn.eecs.berkeley.edu Sat Jun 2 06:55:28 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 22:55:28 -0700 (PDT) Subject: [Tutor] Re: [Python-Help] a number and control char stored in a single char. ! In-Reply-To: <20010602052713.3595.qmail@web13607.mail.yahoo.com> Message-ID: On Fri, 1 Jun 2001, kaha aham wrote: > I am running & capturing screen output of a command using os.popen as > helped by tuto@python.org ppl. However the value i capture which > should be a number like something like 22345 is displayed as > '22345\012' Yes, this means that what you're getting back is the string "21345" followed by the newline, '\012'. What you'll need to do is convert it with the int() function. > I need to numerically compare this value later in program. I tried > slicing it to remove the last control char using var[:-1], on which it > prints []. I then trid using len(), it tells size as 1 char. I tried > printing just 1st char using var[0], and it shows '22345\012' Ah! You had the right idea: what you'll want to do is: var[0][:-1] instead. You want to get all but the last character from var[0], your first line of the output. This is probably what was preventing you from converting to integer. Try int()'ing with var[0][:-1], and you should be ok. But if you're converting with int(), you don't need to strip out the newline character; int() knows how to deal with it already. Let's look at what happened before... I'm guessing that when you used os.popen(), you used the readlines() method to get at all the lines of output. What this means is that "var" stands for all the lines of input, and "var[0]" stands for the first line. However, "var[:-1]" stands for all but the last line --- but if your output only consists of one line, that means you'll get the empty list, []. That should explain the weird error messages. > That's baffling me. How can it put all that number and control char in > 1 char. I currently can't post to tutor maillist as I did earlier. Hmmm... that's strange! Try posting your question again; perhaps the mail host was down. In the meantime, I'll forward your message to tutor@python.org. I just checked, and from what I can tell, you're not subscribed to the tutor list yet. You'll probably need to subscribe to post to tutor. You can subscribe here: http://mail.python.org/mailman/listinfo/tutor If you run into difficulties again, feel free to email again. I'll talk to you later! From dyoo@hkn.eecs.berkeley.edu Sat Jun 2 06:55:39 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 22:55:39 -0700 (PDT) Subject: [Tutor] [Python-Help] a number and control char stored in a single char. ! (fwd) Message-ID: ---------- Forwarded message ---------- Date: Fri, 1 Jun 2001 22:27:13 -0700 (PDT) From: kaha aham To: help@python.org Subject: [Python-Help] a number and control char stored in a single char. ! hello, I am running & capturing screen output of a command using os.popen as helped by tuto@python.org ppl. However the value i capture which should be a number like something like 22345 is displayed as '22345\012' I need to numerically compare this value later in program. I tried slicing it to remove the last control char using var[:-1], on which it prints []. I then trid using len(), it tells size as 1 char. I tried printing just 1st char using var[0], and it shows '22345\012' That's baffling me. How can it put all that number and control char in 1 char. I currently can't post to tutor maillist as I did earlier. I tried int(var) and it says, object cant be converted to int. Can you give a hint how do I resolve this and get the numeric out of it. /psg --------------------------------- Do You Yahoo!? Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail. From dyoo@hkn.eecs.berkeley.edu Sat Jun 2 07:01:50 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 1 Jun 2001 23:01:50 -0700 (PDT) Subject: [Tutor] bitwise operations In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F1@mbtlipnt02.btlabs.bt.co.uk> Message-ID: On Fri, 1 Jun 2001 alan.gauld@bt.com wrote: > > Could anyone tell me all there is to know about bit > > manipulation; > > No, I doubt it. I don'ty think anyone has figured that out yet... Some > things you might like to do a search on the net for are 'Boolean > Algenra' and 'Bitmasks' > > > why a person would want to be fiddling with bits. > > Bits are a compact way of storing a lot of data which is boolean by > nature. > For example software used for bulk processing of a long list of items > might keep a note of which items have changed(and hence need > reprocessing) by adding a boolean value flag to the reords - but that > (a) changes the records and (b) takes up a byte per record. An > altrernative solution is to store a block of memory with a single bit > representing each record, then simply switch that bit on if the reord > changes. Using a bit-wise notation is also a natural way of representing sets. For example, let's say that we'd like to find the intersection of two lists of numbers. For example, let's try to find the intersection between: L1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] L2 = [2, 4, 6, 8, 10, 12] Of course, we know that intersect(L1, L2) = [2, 4, 6, 8, 10], but let's pretend that we didn't know that initially. A way that we can represent L1 is as a list of bits: --------------------------------------------------------- pos 0 1 2 3 4 5 6 7 8 9 10 11 12 --------------------------------------------------------- L1 = 0 1 1 1 1 1 1 1 1 1 1 0 0 L2 = 0 0 1 0 1 0 1 0 1 0 1 0 1 (Traditionally, the bits are listed in reverse order.) The reason that representing L1 and L2 as a bunch of bits is useful is because taking the intersection just involves looking for places where L1 and L2 both have 1: that is, we perform the AND logical operation: --------------------------------------------------------- pos 0 1 2 3 4 5 6 7 8 9 10 11 12 --------------------------------------------------------- L1 = 0 1 1 1 1 1 1 1 1 1 1 0 0 L2 = 0 0 1 0 1 0 1 0 1 0 1 0 1 -------------------------------------------------------- L1 & L2 = 0 0 1 0 1 0 1 0 1 0 1 0 0 And that's exactly what we want to get: by doing the AND, we now know that the intersection between L1 and L2 is [2, 4, 6, 8, 10]. To actually represent L1 in Python is where all those bit operations come into play. The idea in bit manipulation is that we'll try to "pack" a bunch of bits into a Python integer. Every Python integer is actually made up of 32 bits --- that gives us 32 little switches to work with. If we want more bits, we can use another integer to get a block of 32 more bits. Blake Winton's message talks a little more about bit-fiddling stuff, so I'll stop here... *grin* From r.b.rigilink@chello.nl Sat Jun 2 08:05:10 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Sat, 02 Jun 2001 09:05:10 +0200 Subject: [Tutor] Lists... References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk> <00e901c0eb1c$0cb9aac0$0a0a0a0a@mntp1.il.home.com> Message-ID: <3B189026.18DAFC5A@chello.nl> Michael Schmitt wrote: > > Just for fun I added a function using Alan G method to the Roeland's timing > code as follows: > Hi Michael, I don't know why our numbers differ so much (you got 0.00000 in a lot of your timing measurements) Anyway, Alan's method is strictly brute force, just written somewhat differently. Here's what I get (Code follows at the end) Brute force (n=10), t=0.000137 List filter (n=10), t=0.000212 # Alan's code Dict lookup (n=10), t=0.000150 Dict filter (n=10), t=0.000119 Sorted list (n=10), t=0.000426 Brute force (n=100), t=0.006812 List filter (n=100), t=0.006745 Dict lookup (n=100), t=0.001056 Dict filter (n=100), t=0.000680 Sorted list (n=100), t=0.003793 Brute force (n=1000), t=0.831248 List filter (n=1000), t=0.837468 Dict lookup (n=1000), t=0.017591 Dict filter (n=1000), t=0.007191 Sorted list (n=1000), t=0.055949 Brute force (n=10000), t=92.381026 List filter (n=10000), t=92.870684 Dict lookup (n=10000), t=0.151935 Dict filter (n=10000), t=0.124802 Sorted list (n=10000), t=0.532801 i.e Quadratic time behaviour for brute force, linear time for dictinonary based methods and using sorted lists. -- the code from __future__ import nested_scopes def intersect1(l1, l2): '''brute force intersection of two lists''' return [item for item in l1 if item in l2] def intersect2(l1, l2): '''intersection of two lists, using dicts''' dict = {} for item in l2: dict[item] = None return [item for item in l1 if dict.has_key(item)] def intersect2a(l1, l2): '''using dicts with filter, thanks to Remco Gehrlich''' dict = {} for item in l2: dict[item] = 1 return filter(dict.has_key, l1) def intersect3(l1, l2): '''intersection of two sorted lists of unique items''' result = [] lo = 0 hi = len(l2) for i in l1: for j in xrange(lo, hi): n = cmp(l2[j], i) if n==-1: lo = j elif n==1: break else: lo = j result.append(i) break return result def intersect_eas(L1, L2): '''The easiest way for Alan G, requires nested_scopes''' return filter(lambda x: (x in L2), L1) def make_list(n): '''Make a sorted list of unique ints larger than 1''' import random l = [] x = 1 for i in xrange(n): x = x+random.randrange(1, 5) l.append(x) return l def time_func(intersect_func, l1, l2): import time t1 = time.time() l = intersect_func(l1, l2) t2 = time.time()-t1 # print l[0:10] return t2 def test(n): l1 = make_list(n) l2 = make_list(n) print 'Brute force (n=%i), t=%f' % (n, time_func(intersect1, l1, l2)) print 'List filter (n=%i), t=%f' % (n, time_func(intersect_eas, l1, l2)) print 'Dict lookup (n=%i), t=%f' % (n, time_func(intersect2, l1, l2)) print 'Dict filter (n=%i), t=%f' % (n, time_func(intersect2a, l1, l2)) print 'Sorted list (n=%i), t=%f' % (n, time_func(intersect3, l1, l2)) print if __name__=='__main__': test(10) test(100) test(1000) test(10000) -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From rickyp1@frontiernet.net Sat Jun 2 19:49:05 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Sat, 2 Jun 2001 13:49:05 -0500 Subject: [Tutor] Unsubsciption Message-ID: <001c01c0eb94$b3ab2980$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_0019_01C0EB6A.C9C89380 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I thought this tuter thing would help me out, I am a beginner but = instead I am getting alot of messages in my mail box that I dont want. = Please give me the unsubscrition web address. You should add the = unsubscrition address to off email sent. Richard E Parks 2 RickyP1@frontiernet.net =20 ------=_NextPart_000_0019_01C0EB6A.C9C89380 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I thought this tuter thing would help = me out, I am=20 a beginner but instead I am getting alot of messages in my mail box that = I dont=20 want. Please give me the unsubscrition web address. You should add the=20 unsubscrition address to off email sent.
       =20             =    =20             =    =20 Richard E Parks 2
 
------=_NextPart_000_0019_01C0EB6A.C9C89380-- From rickyp1@frontiernet.net Sat Jun 2 19:54:18 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Sat, 2 Jun 2001 13:54:18 -0500 Subject: [Tutor] Please? Message-ID: <003d01c0eb95$6e56a340$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_003A_01C0EB6B.84C7F9A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am a beginner and I am unsubscribing to tuter because I am getting to = many emails at once and none of them are helping me, could you posiblie = try to teach personaly? I am realy eger to learn! Richard E Parks 2 RickyP1@frontiernet.net ------=_NextPart_000_003A_01C0EB6B.84C7F9A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am a beginner and I am unsubscribing = to tuter=20 because I am getting to many emails at once and none of them are helping = me,=20 could you posiblie try to teach personaly? I am realy eger to=20 learn!
       =20             =    =20             =    =20 Richard E Parks 2
       =20             =    =20             =     RickyP1@frontiernet.net
 
------=_NextPart_000_003A_01C0EB6B.84C7F9A0-- From phil@xfr.co.uk Sat Jun 2 20:24:11 2001 From: phil@xfr.co.uk (Philip Kilner) Date: Sat, 02 Jun 2001 20:24:11 +0100 Subject: [Tutor] Unsubsciption In-Reply-To: <001c01c0eb94$b3ab2980$6601a8c0@Parks> References: <001c01c0eb94$b3ab2980$6601a8c0@Parks> Message-ID: Ricky, The unsubscribe info is in the header of every email! In article <001c01c0eb94$b3ab2980$6601a8c0@Parks>, Ricky Parks wrote: > List-Help: > List-Post: > List-Subscribe: , > > List-Id: Discussion for learning programming with Python > List-Unsubscribe: , > > List-Archive: > You might be better staying on the list - you'll learn by watching others learn, and others will learn watching you learn. It's a community thing - it's also more efficient! There are some v. Helpful people on this list, including authors of introductory Python books. It's worth sticking around. HTH, PhilK From sarnold@earthling.net Sat Jun 2 20:37:10 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sat, 2 Jun 2001 12:37:10 -0700 Subject: [Tutor] Unsubsciption In-Reply-To: <001c01c0eb94$b3ab2980$6601a8c0@Parks> Message-ID: <20010602193710.EC3FF1F62A@shiva.arnolds.bogus> On 2 Jun 01, at 13:49, Ricky Parks wrote: > I thought this tuter thing would help me out, I am a beginner > but instead I am getting alot of messages in my mail box that I > dont want. Please give me the unsubscrition web address. You > should add the unsubscrition address to off email sent. Tips: 1) keep the list option emails you receive when you sign up for a list. 2) use a better mailer (like Pegasus) with straight-forward filtering and other options to help you manage mail. 3) don't forget to turn off M$-richcrap-text or html mail (in your mailer settings) - the RFCs define internet email as ASCII text only. 4) stop whining and go here: http://mail.python.org/mailman/listinfo/tutor ************************************************************* Steve Arnold sarnold@earthling.net http://arnolds.dhs.org Java is for staying up late while you program in Python... From sarnold@earthling.net Sat Jun 2 20:55:53 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sat, 2 Jun 2001 12:55:53 -0700 Subject: [Tutor] Unsubsciption In-Reply-To: <20010602193710.EC3FF1F62A@shiva.arnolds.bogus> References: <001c01c0eb94$b3ab2980$6601a8c0@Parks> Message-ID: <20010602195554.0AB7D1F62A@shiva.arnolds.bogus> On 2 Jun 01, at 12:37, Stephen L Arnold wrote: > 1) keep the list option emails you receive when you sign up for a > list. > > 2) use a better mailer (like Pegasus) with straight-forward > filtering and other options to help you manage mail. > > 3) don't forget to turn off M$-richcrap-text or html mail (in your > mailer settings) - the RFCs define internet email as ASCII text > only. > > 4) stop whining and go here: > > http://mail.python.org/mailman/listinfo/tutor Sorry, I didn't intend that last one to sound mean (I've been dealing with a particularly recalcitrant 8 year old all morning). However, the first three are still useful... Steve ************************************************************* Steve Arnold http://arnolds.dhs.org "We've gotta protect our phony-balony jobs, gentlemen!" - Mel Brooks From rickyp1@frontiernet.net Sat Jun 2 20:57:06 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Sat, 2 Jun 2001 14:57:06 -0500 Subject: [Tutor] Ok Message-ID: <003d01c0eb9e$341c3d80$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_003A_01C0EB74.4A85F2C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ok, I am going to stick with it, I will say this agian I am a = beginer an know nothing about programming, so half the stuff that is = sent I will not undersand! Thank you. Richard E Parks 2 RickyP1@frontiernet.net =20 ------=_NextPart_000_003A_01C0EB74.4A85F2C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
    Ok, I am going to = stick with it,=20 I will say this agian I am a beginer an know nothing about programming, = so half=20 the stuff that is sent I will not undersand! Thank = you.
       =20             =    =20             =    =20 Richard E Parks 2
       =20             =    =20             =     RickyP1@frontiernet.net
 
------=_NextPart_000_003A_01C0EB74.4A85F2C0-- From sarnold@earthling.net Sat Jun 2 21:18:24 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sat, 2 Jun 2001 13:18:24 -0700 Subject: [Tutor] Ok - here're some resources In-Reply-To: <003d01c0eb9e$341c3d80$6601a8c0@Parks> Message-ID: <20010602201825.3E5121F62A@shiva.arnolds.bogus> On 2 Jun 01, at 14:57, Ricky Parks wrote: > Ok, I am going to stick with it, I will say this agian I am a > beginer an know nothing about programming, so half the stuff that > is sent I will not undersand! Thank you. If you're really starting from scratch, then Python is definitely the language to start with (then later you could check out Ada :) Try the Non-Programmers Tutorial For Python: http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html How to think like a computer scientist: http://www.ibiblio.org/obp/thinkCSpy/ Learning to program: http://www.crosswinds.net/~agauld/ (this guy is also on the Tutor list) There's also the regular Python Tutorial: http://www.python.org/doc/current/tut/tut.html A Python Short Course: http://www.wag.caltech.edu/home/rpm/python_course/ The What, Why, Who, and Where of Python: http://www.networkcomputing.com/unixworld/tutorial/005/005.html Programming Resources: http://www.cyberramp.net/~fdavid/programming.html and last but not least, John English's Brighton University Resource Kit for Students of computer science (BURKS - its's both a website and a set of inexpensive CD-ROMs). Highly recommended: http://burks.brighton.ac.uk/ That ought to keep you busy for a while ;-) Steve -- Think of the Linux community as a niche economy isolated by its beliefs. Kind of like the Amish, except that our religion requires us to use _higher_ technology than everyone else. -- Donald B. Marti Jr. From r.b.rigilink@chello.nl Sat Jun 2 21:33:00 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Sat, 02 Jun 2001 22:33:00 +0200 Subject: [Tutor] Ok References: <003d01c0eb9e$341c3d80$6601a8c0@Parks> Message-ID: <3B194D7C.F2936AED@chello.nl> > Ricky Parks wrote: > > Ok, I am going to stick with it, I will say this agian I am a > beginer an know nothing about programming, so half the stuff that is > sent I will not undersand! Thank you. > Richard E Parks 2 > RickyP1@frontiernet.net > Hi Ricky, Glad you decided to stick with it. If you run into anything specific you'd like to get help with I hope you'll feel confident enough to send your questions to the list. In that way others will benefit from our answers. If you feel more comfortable with that, I for one don't mind if you send questions privately. Don't worry to much about the stuff that seems way over your head now (we do get carried away sometimes) I think you'll find that things will be much more comprehensible in a few months. Also, don't worry about asking for explanations. Have fun, Roeland Rengelink -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From sak@nwlink.com Sat Jun 2 18:38:42 2001 From: sak@nwlink.com (Sak) Date: Sat, 2 Jun 2001 13:38:42 -0400 Subject: [Tutor] Ok In-Reply-To: <003d01c0eb9e$341c3d80$6601a8c0@Parks> References: <003d01c0eb9e$341c3d80$6601a8c0@Parks> Message-ID: <01060213384200.02128@ci> On Saturday 02 June 2001 15:57, Ricky Parks wrote: > Ok, I am going to stick with it, I will say this agian I am a beginer > an know nothing about programming, so half the stuff that is sent I will > not undersand! Thank you. Richard E Parks 2 > RickyP1@frontiernet.net I can relate Ricky, and I was just thinking about this earlier this morning. I subscribed to this list a couple days ago, with equal fear that I wouldn't understand what the heck was going on. But then I remembered that no knowledge comes as easy as we would like it to. My goal is to work through my Learning Python book (O'Reilly) the tutorial from Python.org, and continue reading the posts to this list. Eventually, it'll make sense. I just think what we complete newbies are feeling is akin to culture-shock. After we immerse ourselves in the stuff for a while it'll make more sense; and that will be a great sense of accomplishment. Thanks, -- Sak. From rob@jam.rr.com Sat Jun 2 22:02:34 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sat, 02 Jun 2001 16:02:34 -0500 Subject: [Tutor] Ok References: <003d01c0eb9e$341c3d80$6601a8c0@Parks> Message-ID: <3B19546A.A98FA32@jam.rr.com> > Ricky Parks wrote: > > Ok, I am going to stick with it, I will say this agian I am a > beginer an know nothing about programming, so half the stuff that is > sent I will not undersand! Thank you. > Richard E Parks 2 > RickyP1@frontiernet.net > Even if learning sometimes takes time (certainly in my case), it's at least always good to be exposed to really decent people. We have plenty of 'em on this list. my $.02 worth, Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From Tutor@python.org Sat Jun 2 22:19:16 2001 From: Tutor@python.org (Tim Peters) Date: Sat, 2 Jun 2001 17:19:16 -0400 Subject: [Tutor] Ok In-Reply-To: <3B19546A.A98FA32@jam.rr.com> Message-ID: [Ricky Parks] > Ok, I am going to stick with it, I will say this agian I am a > beginer an know nothing about programming, so half the stuff that is > sent I will not undersand! Thank you. If you only see stuff you already understand, how would you learn? I've been programming for decades, and I don't understand half of what I see either: it's a very big world out there . Questions at all levels are welcome here. So if the list goes through a period where everything seems over your head, feel free to start new topics on things *you're* wondering about! The biggest problem beginners have is not that they ask "stupid questions", but that too many are nervous about asking any questions at all. Programming is a lot of fun, but there's a lot to learn too. From budgester@budgester.com Sat Jun 2 22:54:39 2001 From: budgester@budgester.com (Martin Stevens) Date: Sat, 2 Jun 2001 22:54:39 +0100 Subject: [Tutor] Mailing List. Message-ID: <20010602225439.A17781@budgester.com> Hi, Probably should be mailing the admins directly but, We use the Mailman software for this list ? On another list I belong to they have set the Reply-to address as the list address, is there a reason we don't do this ? I'm sure it would make things easier, when replying to queries BTW I'm using Mutt on Debian, so there maybe a way of replying to the list automatically. Thanks Martin Stevens a.k.a. Budgester http://www.budgester.com P.S. To all the newbies, keep at it, and have a look at the useless python site, there is some of my code on it that is really simple. Rob, just an idea how about giving the scripts a grade of simple to complex ? From rick@niof.net Sat Jun 2 22:43:07 2001 From: rick@niof.net (Rick Pasotto) Date: Sat, 2 Jun 2001 17:43:07 -0400 Subject: [Tutor] Mailing List. In-Reply-To: <20010602225439.A17781@budgester.com>; from budgester@budgester.com on Sat, Jun 02, 2001 at 10:54:39PM +0100 References: <20010602225439.A17781@budgester.com> Message-ID: <20010602174307.A2841@tc.niof.net> On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote: > > BTW I'm using Mutt on Debian, so there maybe a way of replying > to the list automatically. Put in your .muttrc subscribe tutor and then when you want to reply press 'L' (that's capital-L) for List-reply. -- If man were perfect, if he were infallible, society would present a very different kind of harmony from that which we may actually expect it to offer us. Our idea of harmony is not Fourier's. It does not exclude the existence of evil; it leaves room for discord; and yet we shall recognize that harmony nonetheless exists, provided that discord serves to prepare the way and to lead us back to harmony. -- Frédéric Bastiat (1801-1850) Rick Pasotto rickp@telocity.com http://www.niof.net From rickyp1@frontiernet.net Sat Jun 2 22:50:37 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Sat, 2 Jun 2001 16:50:37 -0500 Subject: [Tutor] Prompt Message-ID: <003401c0ebae$0fd618a0$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C0EB84.26615FA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thank you all for the suport. My bigest problem right now is getiing the = software to run. I downloaded python 2.0 Windows Installer from the = python.org web site. I am still having a problem with the prompt screen = closing too fast I can even read what is says! =20 ------=_NextPart_000_0031_01C0EB84.26615FA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thank you all for the suport. My bigest = problem=20 right now is getiing the software to run. I downloaded python 2.0=20 Windows Installer from the python.org web site. I am still having a = problem  with the prompt screen closing too fast I can = even read=20 what is says! 
------=_NextPart_000_0031_01C0EB84.26615FA0-- From bdupire@seatech.fau.edu Sat Jun 2 23:10:47 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Sat, 02 Jun 2001 18:10:47 -0400 Subject: [Tutor] Prompt References: <003401c0ebae$0fd618a0$6601a8c0@Parks> Message-ID: <3B196467.D2A98C5A@seatech.fau.edu> --------------A213E01662C4705C0DE07A03 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I think we need some more indications to answer your question..... What are you trying to do to get a prompt screen in Windows ? if you have installed python 2.0 on Windows, you should have in Start > Programs> Python 2.0 the following icons: * IDLE (GUI) * Command line * Python manuals * Uninstall Python if you click on the first one, a windows pops up, where you can enter Python commands interactively. If you click on the second one, a MS DOS command windows pops up, where you can enter Python commands interactively too. But it's not closing when you enter a command, such as 3+5. What have you done so far ? Ricky Parks wrote: > Thank you all for the suport. My bigest problem right now is getiing > the software to run. I downloaded python 2.0 Windows Installer from > the python.org web site. I am still having a problem with the prompt > screen closing too fast I can even read what is says! -- Benoit Dupire --------------A213E01662C4705C0DE07A03 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I think we need some more indications to answer your question.....
What are you trying to do to get a prompt screen in Windows ?

if you have installed python 2.0 on Windows, you should have in Start >  Programs> Python 2.0    the  following icons:
* IDLE (GUI)
* Command line
* Python manuals
* Uninstall Python
 

if you click on the first one, a windows pops up, where you can enter Python commands interactively.
If you click on the second one, a MS DOS command windows pops up, where you can enter Python commands interactively too.
But it's not closing when you enter a command, such as 3+5.

What have you done so far ?
 

Ricky Parks wrote:

Thank you all for the suport. My bigest problem right now is getiing the software to run. I downloaded python 2.0 Windows Installer from the python.org web site. I am still having a problem  with the prompt screen closing too fast I can even read what is says!

--
Benoit Dupire
  --------------A213E01662C4705C0DE07A03-- From bdupire@seatech.fau.edu Sat Jun 2 23:22:31 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Sat, 02 Jun 2001 18:22:31 -0400 Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ? References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EC@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <3B196727.7C4FA55D@seatech.fau.edu> alan.gauld@bt.com wrote: > > If one does not exist I would be willing to contribute my > > time. > > You said the magic words. > Feel free, I'm pretty sure there iusn't a tutor-faq yet > and yes we do get a lot of duplication. Just nobody > else has time... > > So I say go for it. > > Alan G. yep.. i began to do such a faq !!!! (but i am late at reading the tutor list!) my first idea was to sumarize the most common threads.. and the best answers but I quickly stopped, because i found that http://python.faqts.com looks a lot like what i was looking for...... the first draft (quite basic) of what i did is at http://www.oe.fau.edu/~bdupire/python/index.html but i figured out i wouldn't have enough time.... All suggestions are welcome... Alan, you can of course use what i did if you want.... > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire From sarnold@earthling.net Sat Jun 2 23:25:37 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sat, 2 Jun 2001 15:25:37 -0700 Subject: [Tutor] Prompt In-Reply-To: <003401c0ebae$0fd618a0$6601a8c0@Parks> Message-ID: <20010602222538.4E8F11F62A@shiva.arnolds.bogus> On 2 Jun 01, at 16:50, Ricky Parks wrote: > Thank you all for the suport. My bigest problem right now is > getiing the software to run. I downloaded python 2.0 Windows > Installer from the python.org web site. I am still having a > problem with the prompt screen closing too fast I can even read > what is says! Are you calling a script from the Start|Run menu, from a DOS box, or IDLE? I'm not sure I can visualize what you're doing. If the pythonwin interface is dying right away, then there's a problem. You might have a corrupted installation, dll problems, etc. You could try the old un-installing/re-installing trick... You might want to try the ActiveState Python distribution for win32. Check out: http://aspn.activestate.com/ASPN/Downloads/ActivePython/ for nice windoze installers for both Python 2.0 and 2.1 (and their Komodo IDE is pretty cool, but it needs some horsepower to run well). Steve ************************************************ Steve Arnold CLE (Certifiable Linux Evangelist) http://arnolds.dhs.org From budgester@budgester.com Sat Jun 2 23:54:05 2001 From: budgester@budgester.com (Martin Stevens) Date: Sat, 2 Jun 2001 23:54:05 +0100 Subject: [Tutor] Mailing List. In-Reply-To: <20010602174307.A2841@tc.niof.net>; from rick@niof.net on Sat, Jun 02, 2001 at 05:43:07PM -0400 References: <20010602225439.A17781@budgester.com> <20010602174307.A2841@tc.niof.net> Message-ID: <20010602235405.A18003@budgester.com> On Sat, Jun 02, 2001 at 05:43:07PM -0400, Rick Pasotto wrote: > On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote: > > > > BTW I'm using Mutt on Debian, so there maybe a way of replying > > to the list automatically. > > Put in your .muttrc > > subscribe tutor > > and then when you want to reply press 'L' (that's capital-L) > for List-reply. > That did the trick thanks ! From budgester@budgester.com Sun Jun 3 00:18:03 2001 From: budgester@budgester.com (Martin Stevens) Date: Sun, 3 Jun 2001 00:18:03 +0100 Subject: [Tutor] Newbie Project Message-ID: <20010603001803.A18034@budgester.com> Hi all, Okay I've had an idea and they are fairly rare ! A little while ago I was writing a python program to update my diary entries on my website. I'd got it 95% complete when my hard drive went down and me with no backups (D'oh). Whilst working on this project I learnt a bit about python and found it quite a good project to learn on. So when a few of the people on the list said they are new to programming I thought about this project. Now comes the idea, what i have done is put a bit of psuedo code on my website that people learning python can contribute to without getting overwhelmed by masses of code. So anybody (even if you've just started) should be able to contribute, but what I don't want to happen is the really good people just pick it up and complete it in 2 hours :-) so how about the Guru people adding to the Ideas section or adding a bit more pseudo code to it so there are extra little challenges ? Hopefully I'm not wasting peoples time with this. let me know what you think. Thanks Martin Stevens. BTW here's the URL http://www.budgester.com/diaryupdate.htm From rickyp1@frontiernet.net Sun Jun 3 00:16:49 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Sat, 2 Jun 2001 18:16:49 -0500 Subject: [Tutor] Prompt 2 Message-ID: <002001c0ebba$1a4be600$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_001D_01C0EB90.30DECE20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable OK, I am going to tell you step by step what I do.I write an small = program in a text editor, save it, there is a problem with my computer = that make me have to associate these kinds of files every time I load it = so I associate it with the Python (command line) and run it. That is = when the prompt screen opens and then closes so fast that I can not read = what is says. Could that have some thing to do with my properties = setting? Python is so confusing to run compared to Qbasic, which I have = been using. Richard E. Parks 2 =20 ------=_NextPart_000_001D_01C0EB90.30DECE20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

    OK, I am going to = tell you step=20 by step what I do.I write an small program in a text editor, save it, = there is a=20 problem with my computer that make me have to associate these kinds = of=20 files every time I load it so I associate it with the Python (command = line) and=20 run it. That is when the prompt screen opens and then closes so = fast that I=20 can not read what is says. Could that have some thing to do with my = properties=20 setting? Python is so confusing to run compared to Qbasic, which I have = been=20 using.
       =20             =    =20             =    =20 Richard E. Parks 2  
------=_NextPart_000_001D_01C0EB90.30DECE20-- From tescoil@irtc.net Sun Jun 3 00:19:29 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sat, 02 Jun 2001 18:19:29 -0500 Subject: [Tutor] Prompt References: <003401c0ebae$0fd618a0$6601a8c0@Parks> Message-ID: <3B197481.CE8930C1@irtc.net> On 2 June 2001, Ricky Parks wrote: > I downloaded python 2.0 Windows Installer from the > python.org web site. I am still having a problem > with the prompt screen closing too fast I can even > read what is says! This would qualify for a Tutor FAQ, although I think it's been a few months since it was last asked: See: http://mail.python.org/pipermail/tutor/2001-January/003073.html and: http://mail.python.org/pipermail/tutor/2001-January/003139.html From cynic@mail.cz Sun Jun 3 00:17:33 2001 From: cynic@mail.cz (cynic@mail.cz) Date: Sat, 2 Jun 2001 19:17:33 -0400 Subject: [Tutor] Newbie Project Message-ID: <200106021917610.SM00784@m2w059> what is the reasoning behing the idea of downloading the current webpage and modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sort = of an XML parser. Original Message: ----------------- From: Martin Stevens budgester@budgester.com Date: Sun, 3 Jun 2001 00:18:03 +0100 To: tutor@python.org Subject: [Tutor] Newbie Project Hi all, Okay I've had an idea and they are fairly rare ! A little while ago I was writing a python program to update my diary entries on my website. I'd got it 95% complete when my hard drive went down and me with no backups (D'oh). Whilst working on this project I learnt a bit about python and found it quite a good project to learn on. So when a few of the people on the list said they are new to programming I thought about this project. Now comes the idea, what i have done is put a bit of psuedo code on my website that people learning python can contribute to without getting overwhelmed by masses of code. So anybody (even if you've just started) should be able to contribute, but what I don't want to happen is the really good people just pick it up and complete it in 2 hours :-) so how about the Guru people adding to the Ideas section or adding a bit more pseudo code to it so there are extra little challenges ? Hopefully I'm not wasting peoples time with this. let me know what you think. Thanks Martin Stevens. BTW here's the URL http://www.budgester.com/diaryupdate.htm _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . From budgester@budgester.com Sun Jun 3 00:59:42 2001 From: budgester@budgester.com (Martin Stevens) Date: Sun, 3 Jun 2001 00:59:42 +0100 Subject: [Tutor] Newbie Project In-Reply-To: <200106021917610.SM00784@m2w059>; from cynic@mail.cz on Sat, Jun 02, 2001 at 07:17:33PM -0400 References: <200106021917610.SM00784@m2w059> Message-ID: <20010603005942.A18119@budgester.com> On Sat, Jun 02, 2001 at 07:17:33PM -0400, cynic@mail.cz wrote: > what is the reasoning behing the idea of downloading the current webpage and > modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sort of an XML parser. > Ok, the way I had it working before was something along these lines. The .htm file is basically a text file and I had a mark in it, the .htm file was read in with readline(s) and the mark was replaced with the new update and a new mark, then reuploaded, this was due to not having any cgi availability on the web server, so while I was downloading my e-mail I could run the program and update the diary. The mark would be something like i.e. a html comment that a browser would ignore. The reason for using python was so that I could run it at work on a windows machine, and at home on Linux, so it had to be cross platform and the only place that I could guarantee had the most recent version of my diary was the actual web page itself. As for XML, I don't really know a great deal about it, I suppose i should really look into it, but this solution worked fine for my purposes and I thought it might be of use to other people. (I also hate web based forms ;-) From gman_95@hotmail.com Sun Jun 3 00:52:15 2001 From: gman_95@hotmail.com (Daryl G) Date: Sat, 02 Jun 2001 23:52:15 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Hi, I am having difficulty in saving and loading data that I created in a simple Address book program. I am using 3 list variables for First and Last name and phone number and an interger that counts the total number of entries. I first tried using the 'write' but that wouldn't work with lists. I discovered the pickle module and I am able to save my data, but when I load it back up and then try to view it in my program, its not there. variables import pickle, string F_Name=[] L_Name=[] PH_num=[] total=0 #savedata method def savedata(): filename= raw_input("Enter the name you wish to give this address book: ") object=(F_Name, L_Name, PH_num, total) file=open(filename, 'w') pickle.dump(object, file) #opendata method def opendata(): filename=raw_input("Enter the name of the Addressbook you wish to open: ") file = open(filename,'r') (F_Name,L_Name, PH_num, total)=pickle.load(file) What am I doing wrong? Another question that I have is how do I format data that I want to display in specific columns in standerd output, like that can be done in C ? Thanks Daryl _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From cynic@mail.cz Sun Jun 3 01:36:09 2001 From: cynic@mail.cz (cynic@mail.cz) Date: Sat, 2 Jun 2001 20:36:09 -0400 Subject: [Tutor] Newbie Project Message-ID: <200106022036909.SM00692@m2w033> ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't th= e goal, right? Original Message: ----------------- From: Martin Stevens budgester@budgester.com Date: Sun, 3 Jun 2001 00:59:42 +0100 To: tutor@python.org Subject: Re: [Tutor] Newbie Project On Sat, Jun 02, 2001 at 07:17:33PM -0400, cynic@mail.cz wrote: > what is the reasoning behing the idea of downloading the current webpage and > modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sor= t of an XML parser. > Ok, the way I had it working before was something along these lines. The .htm file is basically a text file and I had a mark in it, the .htm file was read in with readline(s) and the mark was replaced with the new update and a new mark, then reuploaded, this was due to not having any cgi availability on the web server, so while I was downloading my e-mail I could run the program and update the diary. The mark would be something like i.e. a html comment that a browser would ignore. The reason for using python was so that I could run it at work on a windows machine, and at home on Linux, so it had to be cross platform and the only place that I could guarantee had the most recent version of my diary was the actual web page itself. As for XML, I don't really know a great deal about it, I suppose i should really look into it, but this solution worked fine for my purposes and I thought it might be of use to other people. (I also hate web based forms ;-) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . From deirdre@deirdre.net Sun Jun 3 01:36:46 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sat, 2 Jun 2001 17:36:46 -0700 Subject: [Tutor] Mailing List. In-Reply-To: <20010602225439.A17781@budgester.com> References: <20010602225439.A17781@budgester.com> Message-ID: >On another list I belong to they have set the Reply-to >address as the list address, is there a reason we don't >do this ? Yes -- because it's a bad idea. http://www.unicom.com/pw/reply-to-harmful.html http://marc.merlins.org/perso/listreplyto.txt -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net Macintosh Developer (seeking work): Will work for Cocoa "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From budgester@budgester.com Sun Jun 3 02:07:14 2001 From: budgester@budgester.com (Martin Stevens) Date: Sun, 3 Jun 2001 02:07:14 +0100 Subject: [Tutor] Mailing List. In-Reply-To: ; from deirdre@deirdre.net on Sat, Jun 02, 2001 at 05:36:46PM -0700 References: <20010602225439.A17781@budgester.com> Message-ID: <20010603020714.A18507@budgester.com> On Sat, Jun 02, 2001 at 05:36:46PM -0700, Deirdre Saoirse Moen wrote: > >On another list I belong to they have set the Reply-to > >address as the list address, is there a reason we don't > >do this ? > > Yes -- because it's a bad idea. > > http://www.unicom.com/pw/reply-to-harmful.html > > http://marc.merlins.org/perso/listreplyto.txt > Ooops, Ok read that, and I'll go back and hide under my rock again :-) Found the group reply option in mutt now. From budgester@budgester.com Sun Jun 3 02:12:36 2001 From: budgester@budgester.com (Martin Stevens) Date: Sun, 3 Jun 2001 02:12:36 +0100 Subject: [Tutor] Newbie Project In-Reply-To: <200106022036909.SM00692@m2w033>; from cynic@mail.cz on Sat, Jun 02, 2001 at 08:36:09PM -0400 References: <200106022036909.SM00692@m2w033> Message-ID: <20010603021236.B18507@budgester.com> On Sat, Jun 02, 2001 at 08:36:09PM -0400, cynic@mail.cz wrote: > ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't the goal, right? > You've got it, probably didn't explain it right in the code, I'll add a bit on the webpage. BTW what do you think of the actual idea of helping newbies collaborate on a basic project like this in pricipal ? If there are other small projects like this that people think of I'd be happy to host them as something like sourceforge always seems a bit intimidating, then when they are completed/working we could transfer them over to robs useless python site. From cynic@mail.cz Sun Jun 3 02:00:47 2001 From: cynic@mail.cz (cynic@mail.cz) Date: Sat, 2 Jun 2001 21:00:47 -0400 Subject: [Tutor] Prompt 2 Message-ID: <200106022100369.SM00824@m2w060> I haven't read the previous thread, but this looks like it's not a prompt, but a console window. I suggest you start a co= nsole _prior to_ starting the program (i. e. run command.com and type e. g. C:\>path\to\your\app>myapp.py), or create a b= atch for it, and make sure the "close when finished" (I don't know the exact english desc., and the only win9x sytem I ha= ve at reach is localized) checkbox is unchecked. Original Message: ----------------- From: Ricky Parks rickyp1@frontiernet.net Date: Sat, 2 Jun 2001 18:16:49 -0500 To: Tutor@python.org Subject: [Tutor] Prompt 2 OK, I am going to tell you step by step what I do.I write an small program in a text editor, save it, there is a prob= lem with my computer that make me have to associate these kinds of files every time I load it so I associate it with the = Python (command line) and run it. That is when the prompt screen opens and then closes so fast that I can not read what i= s says. Could that have some thing to do with my properties setting? Python is so confusing to run compared to Qbasic, wh= ich I have been using. Richard E. Parks 2 -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . From cynic@mail.cz Sun Jun 3 02:03:44 2001 From: cynic@mail.cz (cynic@mail.cz) Date: Sat, 2 Jun 2001 21:03:44 -0400 Subject: [Tutor] Newbie Project Message-ID: <200106022103123.SM00776@m2w049> I think it's a neat idea. After all, everybody's newcomer in some field through the whole life. And Python is probably th= e best language to learn programming around. Original Message: ----------------- From: Martin Stevens budgester@budgester.com Date: Sun, 3 Jun 2001 02:12:36 +0100 To: cynic@mail.cz, tutor@python.org Subject: Re: Re: [Tutor] Newbie Project On Sat, Jun 02, 2001 at 08:36:09PM -0400, cynic@mail.cz wrote: > ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't = the goal, right? > You've got it, probably didn't explain it right in the code, I'll add a bit on the webpage. BTW what do you think of the actual idea of helping newbies collaborate on a basic project like this in pricipal ? If there are other small projects like this that people think of I'd be happy to host them as something like sourceforge always seems a bit intimidating, then when they are completed/working we could transfer them over to robs useless python site. -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . From cynic@mail.cz Sun Jun 3 02:11:25 2001 From: cynic@mail.cz (cynic@mail.cz) Date: Sat, 2 Jun 2001 21:11:25 -0400 Subject: [Tutor] Saving and loading data to/from files Message-ID: <20010602211163.SM00804@m2w061> Hi there, I'm not very familiar with Python, but IIRC pickle is meant for serializing data, which is not the same as general persis= tance using files, databases and alike. I'd suggest you use a csv file to save your addresses, read the file a line at a = time, and split it into your variables. the file would look st. like this: XXXXXXXXX start of file XXXXXXXXXXX Doe;Joe;123456 Black;Tom;987654 Clinton;Bill;111222 XXXXXXXXX end of file XXXXXXXXXXX Original Message: ----------------- From: Daryl G gman_95@hotmail.com Date: Sat, 02 Jun 2001 23:52:15 -0000 To: tutor@python.org Subject: [Tutor] Saving and loading data to/from files Hi, I am having difficulty in saving and loading data that I created in a simple Address book program. I am using 3 list variables for First and Last name and phone number and an interger that counts the total number of entries. I first tried using the 'write' but that wouldn't work with lists. I discovered the pickle module and I am able to save my data, but when I load it back up and then try to view it in my program, its not there. variables import pickle, string F_Name=3D[] L_Name=3D[] PH_num=3D[] total=3D0 #savedata method def savedata(): filename=3D raw_input("Enter the name you wish to give this address book: ") object=3D(F_Name, L_Name, PH_num, total) file=3Dopen(filename, 'w') pickle.dump(object, file) #opendata method def opendata(): filename=3Draw_input("Enter the name of the Addressbook you wish to open: ") file =3D open(filename,'r') (F_Name,L_Name, PH_num, total)=3Dpickle.load(file) What am I doing wrong? Another question that I have is how do I format data that I want to display in specific columns in standerd output, like that can be done in C ? Thanks Daryl _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . From sarnold@earthling.net Sun Jun 3 02:12:37 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sat, 2 Jun 2001 18:12:37 -0700 Subject: [Tutor] Prompt 2 In-Reply-To: <002001c0ebba$1a4be600$6601a8c0@Parks> Message-ID: <20010603011238.2500A1F62A@shiva.arnolds.bogus> On 2 Jun 01, at 18:16, Ricky Parks wrote: > Python is so confusing to run compared to Qbasic, which I > have been using. Have you guys tried running things from within PythonWin or Komodo initially? At least until it's working to your satisfaction (then you can call it with pythonw.exe). You should be able to run some things inter-actively, as well as run script files directly. Of course, I'm using the ActiveState Python 2.0 build 203, but it works for me. Steve ************************************************************* Steve Arnold http://arnolds.dhs.org Things go better with Linux and King Crimson. From dyoo@hkn.eecs.berkeley.edu Sun Jun 3 02:33:35 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 2 Jun 2001 18:33:35 -0700 (PDT) Subject: [Tutor] Ok In-Reply-To: Message-ID: On Sat, 2 Jun 2001, Tim Peters wrote: > [Ricky Parks] > > Ok, I am going to stick with it, I will say this agian I am a > > beginer an know nothing about programming, so half the stuff that is > > sent I will not undersand! Thank you. > > If you only see stuff you already understand, how would you learn? I've > been programming for decades, and I don't understand half of what I see > either: it's a very big world out there . > > Questions at all levels are welcome here. So if the list goes through > a period where everything seems over your head, feel free to start new > topics on things *you're* wondering about! The biggest problem And stop us when we start sounding really incomprehensible! That probably means that we're not doing a good job in explaining things. Good luck to you. From gman_95@hotmail.com Sun Jun 3 02:47:32 2001 From: gman_95@hotmail.com (Daryl G) Date: Sun, 03 Jun 2001 01:47:32 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Hi, Unfortunatly, I don't know what a csv file is -sorry. I have tried the one line at a time approach, but from I could tell python wouldn't allow this wiht the list type. At least not with the file.write() . It would give an error with list variable. It said it was a read only character buffer. The write method only works with primitive types; not lists, tuples, or dictionarys. I have, however, discovered that it is infact reading in the data from a file when I am using the pickle method. I verified this by adding a print statement in my opendata method and it showed that it had read in the data. The problem appears to be in my function that displays the information. I can't figure out why it doesn't work Thanks. #listdata method to display contents of Address book #will display info if just added, but will not display info if just #loaded from a file def listdata(): i=0 total=len(L_Name) print total print "Names and phone numbers in database so far" print print """Last Name First Name PH#""" for i in range(total): print L_Name[i], print " ",F_Name[i], print "\t\t",PH_num[i] >From: "cynic@mail.cz" >Reply-To: cynic@mail.cz >To: "gman_95@hotmail.com" , "tutor@python.org" > >Subject: RE: [Tutor] Saving and loading data to/from files >Date: Sat, 2 Jun 2001 21:11:25 -0400 > >Hi there, > >I'm not very familiar with Python, but IIRC pickle is meant for serializing >data, which is not the same as general persistance using files, databases >and alike. I'd suggest you use a csv file to save your addresses, read the >file a line at a time, and split it into your variables. the file would >look st. like this: > >XXXXXXXXX start of file XXXXXXXXXXX >Doe;Joe;123456 >Black;Tom;987654 >Clinton;Bill;111222 >XXXXXXXXX end of file XXXXXXXXXXX > > >Original Message: >----------------- >From: Daryl G gman_95@hotmail.com >Date: Sat, 02 Jun 2001 23:52:15 -0000 >To: tutor@python.org >Subject: [Tutor] Saving and loading data to/from files > > >Hi, I am having difficulty in saving and loading data that I created in a >simple Address book program. I am using 3 list variables for First and >Last >name and phone number and an interger that counts the total number of >entries. I first tried using the 'write' but that wouldn't work with >lists. >I discovered the pickle module and >I am able to save my data, but when I load it back up and then try to view >it in my program, its not there. > >variables >import pickle, string > >F_Name=[] >L_Name=[] >PH_num=[] >total=0 > >#savedata method >def savedata(): > filename= raw_input("Enter the name you wish to give this address >book: >") > object=(F_Name, L_Name, PH_num, total) > file=open(filename, 'w') > pickle.dump(object, file) > >#opendata method >def opendata(): > filename=raw_input("Enter the name of the Addressbook you wish to >open: >") > file = open(filename,'r') > (F_Name,L_Name, PH_num, total)=pickle.load(file) > > >What am I doing wrong? >Another question that I have is how do I format data that I want to display >in specific >columns in standerd output, like that can be done in C ? >Thanks >Daryl >_________________________________________________________________ >Get your FREE download of MSN Explorer at http://explorer.msn.com > > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor > >-------------------------------------------------------------------- >Mail2Web - Check your email from the web at >http://www.mail2web.com/ . > _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From rear@sirius.com Sun Jun 3 03:05:53 2001 From: rear@sirius.com (Bob Rea) Date: Sat, 2 Jun 2001 19:05:53 -0700 Subject: [Tutor] Ok In-Reply-To: References: Message-ID: <01060219055304.00987@gandalf> On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote: > And stop us when we start sounding really incomprehensible! That > probably means that we're not doing a good job in explaining > things. Hmmm, well... sometimes references on a topic might be useful to a newbie like me like some references on basic algorithms for beginners? very basic, please sorting, for instance -- Bob Rea Freedom is only privilege extended unless enjoyed by one and all --Billy Bragg rear@sirius.com http://www.sirius.com/~rear From rick@niof.net Sun Jun 3 03:41:20 2001 From: rick@niof.net (Rick Pasotto) Date: Sat, 2 Jun 2001 22:41:20 -0400 Subject: [Tutor] Ok In-Reply-To: <01060219055304.00987@gandalf>; from rear@sirius.com on Sat, Jun 02, 2001 at 07:05:53PM -0700 References: <01060219055304.00987@gandalf> Message-ID: <20010602224120.B2841@tc.niof.net> On Sat, Jun 02, 2001 at 07:05:53PM -0700, Bob Rea wrote: > On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote: > > And stop us when we start sounding really incomprehensible! That > > probably means that we're not doing a good job in explaining > > things. > > Hmmm, well... > sometimes references on a topic might be useful to a newbie like me > like some references on basic algorithms for beginners? > very basic, please > sorting, for instance But sorting is an advanced topic, more suited to a lower level programming language. If you are in fact a newbie, python's builtin sorting is more than adequate for any tasks you are likely to tackle. This list should be for learning *python* with a little bit of programming technique thrown in. YMMV -- Political economy has not been given the mission of finding out what society would be like if it had pleased God to make man different from what he is. It may be regrettable that Providence, at the beginning, neglected to seek the advice of some of our modern reformers... if He had not disregarded the advice of Fourier, the social order would have borne no resemblance to the one in which we are obliged to live, breathe, and move about. But, since we are in it, since we of live, move, and have our being in it, our only recourse is to study it and to understand its laws, especially if the improvement of our condition essentially depends upon such knowledge. -- Frédéric Bastiat (1801-1850) Rick Pasotto rickp@telocity.com http://www.niof.net From python_newbei@hotmail.com Sun Jun 3 04:47:25 2001 From: python_newbei@hotmail.com (sean schroeder) Date: Sun, 03 Jun 2001 03:47:25 -0000 Subject: [Tutor] new to python... Message-ID: Hello, I am a heavy Perl programmer and very interested in learning how to use Python - mainly for the following type of tasks: - cgi scripting - databases access (mysql, oracle, postgress) - Reading and writing to files. I have begun using Perl's OOP functionality, but believe that Python is better suited for the UML and OOPD methodologies that I have embarked on. Last Note: is there a Python compiler avaialable for either Linux or NT? So, with the above information in mind. I am looking for a resource that will help me easily make the transition. More specifically I am looking for a PDF or book that basically shows/explains how to mvoe from Perl to Python as painlessly as possible. thanks Sean Schroeder _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From dyoo@hkn.eecs.berkeley.edu Sun Jun 3 06:37:38 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 2 Jun 2001 22:37:38 -0700 (PDT) Subject: [Tutor] Please? In-Reply-To: <003d01c0eb95$6e56a340$6601a8c0@Parks> Message-ID: On Sat, 2 Jun 2001, Ricky Parks wrote: > I am a beginner and I am unsubscribing to tuter because I am getting > to many emails at once and none of them are helping me, could you > posiblie try to teach personaly? I am realy eger to learn! Dear Ricky, If you're getting overwhelmed by tutor email, you can set the mailing list up so it bundles the messages up into larger "digests". Visit: http://mail.python.org/mailman/listinfo/tutor and at the bottom of the page, you'll see something about editing your own options. That page also allows you to unsubscribe if you want. Good luck to you. From dyoo@hkn.eecs.berkeley.edu Sun Jun 3 07:06:23 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 2 Jun 2001 23:06:23 -0700 (PDT) Subject: [Tutor] new to python... [transition from perl->python] In-Reply-To: Message-ID: On Sun, 3 Jun 2001, sean schroeder wrote: > I am a heavy Perl programmer and very interested in learning how to > use Python - mainly for the following type of tasks: > - cgi scripting > - databases access (mysql, oracle, postgress) > - Reading and writing to files. You'll definitely want to look at the topic pages on Web (CGI) scripting and Databases here: http://python.org/topics/web/ http://python.org/topics/database/ There are introductions there that will help get you up to speed on this. > Last Note: is there a Python compiler avaialable for either Linux or NT? Not yet. I believe that a compiler for Microsoft's .NET platform is being developed, so you might want to ask on comp.lang.python for more details on that. > So, with the above information in mind. I am looking for a resource > that will help me easily make the transition. More specifically I am > looking for a PDF or book that basically shows/explains how to mvoe > from Perl to Python as painlessly as possible. Hmmm... try the official tutorial: http://python.org/doc/current/tut/tut.html It assumes experience with a programming language like Perl or C++. The other tutorials on: http://python.org/doc/Intros.html should also be helpful for you. After you go through the official tutorial, you should be ok. Here are a list of some caveats in the transition from Perl to Python: String interpolation --- Python doesn't automatically interpolate into strings: there's a separate string formatting operator '%'. So, for example, in Perl, we could do something like this: ### $name = "sean"; $sentence = "Hello $name"; ### The equivalent in Python would be: ### name = "sean" sentence = "Hello %s" % (name) ### The official tutorial touches on this under the "Fancier Output Formatting" topic: http://python.org/doc/current/tut/node9.html#SECTION009100000000000000000 Integer Division --- Python has a distinction between integer division and floating point division. It's different in Perl, since Perl uses floating point throughout. ### half = 1 / 2 ### won't assign .5 to our 'half' variable in Python --- we'll get 0. String manipulation --- Python's uses the idea that strings are immutable, so, if we have something like: ### myline = "Hello, I am a line with a trailing newline.\n" ### to get rid of that last character, we don't have Perl's chomp() operator, but we do have something similar: ### myline = myline.strip() ### Take off the trailing newline. ### An alternative way to take off that last character includes: ### myline = myline[:-1] ## Keep all but the last character ### which you can think of almost like chop(). When you're working with Python, keep the immutability of strings in mind. The tutorial will cover how do to string manipulation, so we'll leave the details there. Those are the big ones I can think of at the moment. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Sun Jun 3 07:26:03 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 2 Jun 2001 23:26:03 -0700 (PDT) Subject: [Tutor] Ok In-Reply-To: <01060219055304.00987@gandalf> Message-ID: On Sat, 2 Jun 2001, Bob Rea wrote: > On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote: > > And stop us when we start sounding really incomprehensible! That > > probably means that we're not doing a good job in explaining > > things. > > Hmmm, well... > sometimes references on a topic might be useful to a newbie like me > like some references on basic algorithms for beginners? > very basic, please > sorting, for instance Donald Knuth's "Art of Computer Programming" is the book I look at when I want to look at a reference, but it's REALLY DENSE reading. I do not recommend his book if you're just starting out on programming. His books are very good (and they have beautiful typography), but the can also be a little intimidating at first. *grin* Hmmm... if you want to see some Computer Science ideas, there's a nice book called "How to Think Like a Computer Scientist", by Allen Downey: http://www.ibiblio.org/obp/ which introduces these ideas using Python; I've heard good things about this book, so feel free to take a look at it. Usually though, we don't focus on algorithms as much as on using Python effectively. When a task looks like it needs an algorithm, we try to direct people toward things that do most of the hard work for them. For example, in sorting a list of names, we can take advantage of the sort() that the list already knows about: ### >>> stooges = ['larry', 'moe', 'curly'] >>> stooges.sort() >>> stooges ['curly', 'larry', 'moe'] ### If you have any questions, feel free to ask us at tutor! From sburr@mac.com Sun Jun 3 07:35:12 2001 From: sburr@mac.com (Steven Burr) Date: Sat, 2 Jun 2001 23:35:12 -0700 Subject: [Tutor] bitwise operations In-Reply-To: <8551136CB6F6D311811B00508B8B92E0C897C0@mail.rpmtec.com> Message-ID: <20010603063340.FIRW12680.femail19.sdc1.sfba.home.com@localhost> On Friday, June 1, 2001, at 06:53 AM, Blake Winton (Screaming) wrote: >>> Could anyone tell me all there is to know about bit >>> manipulation; >> No, I doubt it. I don'ty think anyone has figured >> that out yet... Some things you might like to do >> a search on the net for are 'Boolean Algenra' >> and 'Bitmasks' > > Okay, but surely we could give Craig a short overview... I'm writing mostly to thank Craig for asking this question, which I've also wondered about, and Blake for writing his "short" overview, which was one of the clearest explanations of a difficult topic I've read on this list. And that's saying something. But I also wanted to mention that in making my way through the wonderful 2nd ed. of "Programming Python," I came across another interesting example of using bitwise operations. Some of the functions in the os module, such as os.system, return a 2 byte (16 bit) integer that packs the exit status of the function in the "high" (i.e. left-hand) byte and the the number of the signal that killed the function in the low byte. So if you need to know the exit status of a process (which apparently can be useful in "inter-process communications"), you nab this return value and shift it 8 bits to the right. Suppose for example you have the following script in a file named graucho.py: import sys print "Hello, I must be going." sys.exit(42) You can call it, grab its return value and extract the exit status like so: >>> import os >>> ret = os.system('python graucho.py') Hello, I must be going. >>> ret >> 8 42 From rob@jam.rr.com Sun Jun 3 07:41:55 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sun, 03 Jun 2001 01:41:55 -0500 Subject: [Tutor] new to python... References: Message-ID: <3B19DC33.AFAA0322@jam.rr.com> sean schroeder wrote: > > Hello, > > I am a heavy Perl programmer and very interested in learning how to use > Python - mainly for the following type of tasks: > - cgi scripting > - databases access (mysql, oracle, postgress) > - Reading and writing to files. > > I have begun using Perl's OOP functionality, but believe that Python is > better suited for the UML and OOPD methodologies that I have embarked on. > > Last Note: is there a Python compiler avaialable for either Linux or NT? > > So, with the above information in mind. I am looking for a resource that > will help me easily make the transition. More specifically I am looking for > a PDF or book that basically shows/explains how to mvoe from Perl to Python > as painlessly as possible. > > thanks > Sean Schroeder > You might want to check these out. This is a page of links to tutorials, accompanied by brief descriptions of each. Some are designed with Perl programmers and the like in mind: http://www.lowerstandard.com/python/tutoriallinks.html Python is great for working with CGI and other forms of web programming. You may be interested in *Programming Python, 2nd edition* once you become somewhat familiar with Python. It covers the areas you expressed interest in with some considerable detail, in a tutorial style. Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From dyoo@hkn.eecs.berkeley.edu Sun Jun 3 09:52:34 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 3 Jun 2001 01:52:34 -0700 (PDT) Subject: [Tutor] Saving and loading data to/from files In-Reply-To: Message-ID: On Sun, 3 Jun 2001, Daryl G wrote: > Unfortunatly, I don't know what a csv file is -sorry. I have tried the one A "csv" file is a file where all the fields as separated by commas. It's nice to save data like this because it's fairly easy to separate a comma-separated line back into its pieces: ### >>> line = 'Daryl,gman_95@hotmail.com,tutor@python.org' >>> user, email, mailing_list = string.split(line, ',') >>> user, email, mailing_list ('Daryl', 'gman_95@hotmail.com', 'tutor@python.org') ### I'm not quite sure what each of the letters stand for though. Comma Separated... Vormat? *grin* Many programs know how to write their output in csv format. For example, Microsoft Excel knows how to write spreadsheets in csv. This message will be long, but don't skip it because I think I found the bug in your program. > Unfortunatly, I don't know what a csv file is -sorry. I have tried the > one line at a time approach, but from I could tell python wouldn't > allow this wiht the list type. At least not with the file.write() . It > would give an error with list variable. It said it was a read only > character buffer. The write method only works with primitive types; > not lists, tuples, or dictionarys. Hmmm... can you show us how you're writing to the file? That'll help us give advice on how to get things working. > I have, however, discovered that it is infact reading in the data from > a file when I am using the pickle method. I verified this by adding a > print statement in my opendata method and it showed that it had read > in the data. Ah, good! > The problem appears to be in my function that displays the > information. I can't figure out why it doesn't work Thanks. Ok, let's take a look. > #listdata method to display contents of Address book > #will display info if just added, but will not display info if just > #loaded from a file > > def listdata(): > i=0 > total=len(L_Name) > print total > print "Names and phone numbers in database so far" > print > print """Last Name First Name PH#""" > > for i in range(total): > print L_Name[i], > print " ",F_Name[i], > print "\t\t",PH_num[i] >From what I can tell, this looks ok. It's using global variables, which always make me involuntarily nervous, but that's ok. *grin* What I think is going on is exactly global variable stuff. Let's take a look at the loading part of your program. ### import pickle, string F_Name=[] L_Name=[] PH_num=[] total=0 # [some code cut] #opendata method def opendata(): filename=raw_input("Enter the name of the Addressbook you wish to open: ") file = open(filename,'r') (F_Name,L_Name, PH_num, total)=pickle.load(file) ### Yes, the bug that you're running into has to do with local variable stuff. What I mean is that, in your opendata() function, you have the line: (F_Name,L_Name, PH_num, total)=pickle.load(file) In functions, Python will expect the variables inside to be "local", and that means that any changes you make to variables inside opendata() stay isolated from the rest of the program. Usually, this is a good thing, because this sort of sandboxing keeps us from messing with another part of a program accidently. And you're seeing this because, as long as we're in opendata(), we can see that the file loaded successfully. But those variables "outside" the sandbox, in Global-land, haven't been touched, so that's why the listdata() doesn't show any changes. In this case, what you want is to make the change to F_Name, L_name, PH_num, and total to be "global", so that the rest of the program knows that those variables changed. What you'll need to do is add the line: global F_Name, L_Name, PH_num, total at the very beginning of your opendata() function, which tells Python to take off the sandbox for those specific variables. With this change, your opendata() will look like this: ### def opendata(): global F_Name, L_Name, PH_num, total filename=raw_input("Enter the name of the Addressbook you wish to open: ") file = open(filename,'r') (F_Name,L_Name, PH_num, total)=pickle.load(file) ### and that should fix the bug. Having said that, it's usually a good idea to avoid global variables. There are usually good ways of rearranging things so that globals aren't necessary... but we can talk about that on another message. Hope this helps! If you have more questions, feel free to ask us. From lonetwin@yahoo.com Sun Jun 3 11:04:16 2001 From: lonetwin@yahoo.com (steve) Date: Sun, 3 Jun 2001 15:34:16 +0530 Subject: [Tutor] Prompt 2 In-Reply-To: <002001c0ebba$1a4be600$6601a8c0@Parks> References: <002001c0ebba$1a4be600$6601a8c0@Parks> Message-ID: <01060315334600.10411@mercury.in.cqsl.com> Hey there Ricky, > > OK, I am going to tell you step by step what I do.I write an smal= l > program in a text editor, save it, there is a problem with my computer = that > make me have to associate these kinds of files every time I load it so = I > associate it with the Python (command line) and run it. That is when th= e > prompt screen opens and then closes so fast that I can not read what is > says. Could that have some thing to do with my properties setting? Pyth= on > is so confusing to run compared to Qbasic, which I have been using. Ric= hard > E. Parks 2 I've been looking at u r mails since u joined in....looks like u r one o= f=20 the as-new-as-can be newbie :)....ok here's the reply to u r question: B'fore I go to the exact answer, lemme explain a few things... Python is a intepreted language, (I know u knew that...just trying to= be=20 complete...don't get offended if something sounds insulting to u r=20 knowledge)...but unlike qbasic it has an interactive prompt intepreter to= o,=20 this helps u to try each python statement interactively b4 u put it all=20 together in a file and make a total working program out of it. When u invoke this, what u see is a ">>>" prompt with the version and o= ther=20 info in a small window, that "looks" like the dos command prompt....on th= e=20 other hand after writing the whole program, if u want to execute it what=20 "should" do is open a MS-DOS commond prompt (Start>Program Files>MS-DOS=20 Prompt) and type in c:\[path-to-wherever]> python myproggy.py This will execute u r file (assuming that python.exe is in ur path=20 variable, and u r within the same directory where u have stored ur file=20 [myproggy.py]. This brings us to what "I think" U are doing...u are creating the fil= e,=20 saving it as myproggy.py, associating it with pytyhon and "double-clickin= g"=20 it....what this does is calls the intepreter (b'cos of the=20 association)....executes the proggy (b'cos it is a nice, working python=20 program)...and "closes" the intepreter window ('cos it has nothing else t= o do=20 )...now if u do wanna check if this is what is happening....that's simple= ,=20 insert the statement=20 raw_input() somewhere in u r program...what this will do is wait for u to= =20 enter some-input followed by an enter...b4 going to the next statement...= =2E U'll know whats happening....hope this helps....if it doesn't or if somet= hing=20 strange happens (like u r hard-disk goes up in flames) feel free to ask t= he=20 tutor list again :) Peace Steve P.S: the guys on this list are "very" helpful....change u r attitude, be=20 positive 'bout learning ...an' they'll be more than glad to help u out. --=20 |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##||=09 |||/\##|||||||||##/\||=09 |/ \#########/ \=09 |\ \#######/ /=09 ||\____/#######\____/|=09 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09 Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D From lumbricus@gmx.net Sun Jun 3 11:10:29 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sun, 3 Jun 2001 12:10:29 +0200 Subject: [Tutor] Mailing List. In-Reply-To: <20010602174307.A2841@tc.niof.net>; from rick@niof.net on Sat, Jun 02, 2001 at 05:43:07PM -0400 References: <20010602225439.A17781@budgester.com> <20010602174307.A2841@tc.niof.net> Message-ID: <20010603121029.A1744@Laplace.localdomain> On Sat, Jun 02, 2001 at 05:43:07PM -0400, Rick Pasotto wrote: > On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote: > > > > BTW I'm using Mutt on Debian, so there maybe a way of replying > > to the list automatically. > > Put in your .muttrc > > subscribe tutor there is a line where you can switch on a _Subject:_ in your header, too good luck!! > > and then when you want to reply press 'L' (that's capital-L) > for List-reply. > HTH Joe! -- In order to discover who you are, first learn who everybody else is; you're what's left. From craig@osa.att.ne.jp Sun Jun 3 11:43:37 2001 From: craig@osa.att.ne.jp (Craig Hagerman) Date: Sun, 03 Jun 2001 19:43:37 +0900 Subject: [Tutor] bitwise operations Message-ID: Hi, I want to say a big thank you to Alan Gauld, Blake Winton (GREAT explanation Blake) and Daniel Yoo for the excellant responses to my question about using bitwise operations. I now have a very general, overview kind of understanding about how and why one deals with bits. But I will have to play around and give myself some simple learning tasks to work through to really get a handle on this stuff. You guys have given me enough of an understanding that I now have a place to start. Ironically, I just got a new order of books from Amazon and was fliping though "A programmers guide to Java Certification" and came upon a couple more simple examples of bit usage (different language but the principle is the same). Again, thanks for taking the time to impart your knowledge. Craig Hagerman From tescoil@irtc.net Sun Jun 3 11:49:16 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sun, 03 Jun 2001 05:49:16 -0500 Subject: [Tutor] Saving and loading data to/from files References: Message-ID: <3B1A162C.E897E397@irtc.net> On 3 Jun 2001, Daniel Yoo wrote: > I'm not quite sure what each of the letters stand > for though. Comma Separated... Vormat? *grin* Comma Separated Variable, or, Computer Spreadsheet Vomitus, depending on who you ask... From arcege@speakeasy.net Sun Jun 3 12:52:12 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sun, 3 Jun 2001 07:52:12 -0400 (EDT) Subject: [Tutor] Saving and loading data to/from files In-Reply-To: from "Daryl G" at Jun 02, 2001 11:52:15 PM Message-ID: <200106031152.f53BqDK07773@dsl092-074-184.bos1.dsl.speakeasy.net> Daryl G wrote > > Hi, I am having difficulty in saving and loading data that I created in a > simple Address book program. I am using 3 list variables for First and Last > name and phone number and an interger that counts the total number of > entries. I first tried using the 'write' but that wouldn't work with lists. > I discovered the pickle module and > I am able to save my data, but when I load it back up and then try to view > it in my program, its not there. > > variables > import pickle, string > > F_Name=[] > L_Name=[] > PH_num=[] > total=0 > > #savedata method > def savedata(): > filename= raw_input("Enter the name you wish to give this address book: > ") > object=(F_Name, L_Name, PH_num, total) > file=open(filename, 'w') > pickle.dump(object, file) > > #opendata method > def opendata(): > filename=raw_input("Enter the name of the Addressbook you wish to open: > ") > file = open(filename,'r') > (F_Name,L_Name, PH_num, total)=pickle.load(file) > > > What am I doing wrong? You are assigning to local variables in opendata() when the variables are global in savedata. However you might want to think about passing values, especially removing the raw_input() calls from the functions. def opendata(filename): global F_Name, L_Name, PH_num, total file = open(filename, 'r') (F_Name, L_Name, PH_num, total) = pickle.load(file) Or better yet, returning the values: def opendata(filename): file = open(filename, 'r') # assigning to all values catches the error of invalid data format (F_Name, L_Name, PH_num, total) = pickle.load(file) return (F_Name, L_Name, PH_num, total) Pickle is fine for outputting single values, but for a database of values (like an address) you will want to look at the shelve module (which uses pickle and the *dbm modules, see "anydbm") or a relational database (which could be overkill for an address book application). > Another question that I have is how do I format data that I want to display > in specific > columns in standerd output, like that can be done in C ? This is done with the string % operator. With an order sequence: print '''Name: %s %s; Phone: %s''' % (F_Name, L_Name, PH_num) or with a dictionary: print '''Name: %(first)s %(last)s; Phone: %(phone)s''' % { 'first': F_Name, 'last': L_Name, 'phone': PH_num } The Python Library documention has all this. Much of it is actually like C's sprintf. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From arcege@speakeasy.net Sun Jun 3 12:53:23 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sun, 3 Jun 2001 07:53:23 -0400 (EDT) Subject: [Tutor] Ok In-Reply-To: from "Daniel Yoo" at Jun 02, 2001 06:33:35 PM Message-ID: <200106031153.f53BrNP07783@dsl092-074-184.bos1.dsl.speakeasy.net> Daniel Yoo wrote > And stop us when we start sounding really incomprehensible! That probably > means that we're not doing a good job in explaining things. Guilty, sometimes. ;) -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From lha2@columbia.edu Sun Jun 3 15:21:40 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Sun, 03 Jun 2001 10:21:40 -0400 Subject: [Tutor] Something to tack on to "Useless Python" challenges Message-ID: <3B1A47F4.72959659@mail.verizon.net> http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html Python should be up to the task... Anyone have a module lying around for torking with arbitrarily large numbers (in Python)? From gman_95@hotmail.com Sun Jun 3 15:39:22 2001 From: gman_95@hotmail.com (Daryl G) Date: Sun, 03 Jun 2001 14:39:22 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Yup, it was the global/local problem. I thought that since I had those varibles declared globally, they would be scene everywere, but local varibles take precedence. Forgot about that The %s doesn't quite work right. If a name is shorter than another, then the positions wont be right in my simple table. I guess I have to see if that center() method will work for me. example LastName FirstName Phone# Stephanopolis George 900-856-2992 Jo Mary 800-328-6387 is what I end up getting. Thanks. I'll check that api doc Computer Spreadsheet Vomitus. I love that. :) >From: "Michael P. Reilly" >Reply-To: arcege@speakeasy.net >To: gman_95@hotmail.com (Daryl G) >CC: tutor@python.org >Subject: Re: [Tutor] Saving and loading data to/from files >Date: Sun, 3 Jun 2001 07:52:12 -0400 (EDT) > >Daryl G wrote > > > > Hi, I am having difficulty in saving and loading data that I created in >a > > simple Address book program. I am using 3 list variables for First and >Last > > name and phone number and an interger that counts the total number of > > entries. I first tried using the 'write' but that wouldn't work with >lists. > > I discovered the pickle module and > > I am able to save my data, but when I load it back up and then try to >view > > it in my program, its not there. > > > > variables > > import pickle, string > > > > F_Name=[] > > L_Name=[] > > PH_num=[] > > total=0 > > > > #savedata method > > def savedata(): > > filename= raw_input("Enter the name you wish to give this address >book: > > ") > > object=(F_Name, L_Name, PH_num, total) > > file=open(filename, 'w') > > pickle.dump(object, file) > > > > #opendata method > > def opendata(): > > filename=raw_input("Enter the name of the Addressbook you wish to >open: > > ") > > file = open(filename,'r') > > (F_Name,L_Name, PH_num, total)=pickle.load(file) > > > > > > What am I doing wrong? > >You are assigning to local variables in opendata() when the variables >are global in savedata. However you might want to think about passing >values, especially removing the raw_input() calls from the functions. > >def opendata(filename): > global F_Name, L_Name, PH_num, total > file = open(filename, 'r') > (F_Name, L_Name, PH_num, total) = pickle.load(file) > >Or better yet, returning the values: >def opendata(filename): > file = open(filename, 'r') > # assigning to all values catches the error of invalid data format > (F_Name, L_Name, PH_num, total) = pickle.load(file) > return (F_Name, L_Name, PH_num, total) > >Pickle is fine for outputting single values, but for a database of >values (like an address) you will want to look at the shelve module >(which uses pickle and the *dbm modules, see "anydbm") or a relational >database (which could be overkill for an address book application). > > > Another question that I have is how do I format data that I want to >display > > in specific > > columns in standerd output, like that can be done in C ? > >This is done with the string % operator. With an order sequence: > print '''Name: %s %s; Phone: %s''' % (F_Name, L_Name, PH_num) >or with a dictionary: > print '''Name: %(first)s %(last)s; Phone: %(phone)s''' % { > 'first': F_Name, 'last': L_Name, 'phone': PH_num > } > >The Python Library documention has all this. Much of it is actually >like C's sprintf. > > > -Arcege > >-- >+----------------------------------+-----------------------------------+ >| Michael P. Reilly | arcege@speakeasy.net | _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From sheila@thinkspot.net Sun Jun 3 16:01:18 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 03 Jun 2001 08:01:18 -0700 Subject: [Tutor] Saving and loading data to/from files In-Reply-To: <3B1A162C.E897E397@irtc.net> References: <3B1A162C.E897E397@irtc.net> Message-ID: <1A07617500E0@kserver.org> I thought it was Comma Separated Values -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Sun, 03 Jun 2001 05:49:16 -0500, Tesla Coil wrote about Re: [Tutor] Saving and loading data to/from files: :On 3 Jun 2001, Daniel Yoo wrote: :> I'm not quite sure what each of the letters stand :> for though. Comma Separated... Vormat? *grin* : :Comma Separated Variable, or, :Computer Spreadsheet Vomitus, :depending on who you ask... : : :_______________________________________________ :Tutor maillist - Tutor@python.org :http://mail.python.org/mailman/listinfo/tutor From scarblac@pino.selwerd.nl Sun Jun 3 16:07:55 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 3 Jun 2001 17:07:55 +0200 Subject: [Tutor] Something to tack on to "Useless Python" challenges In-Reply-To: <3B1A47F4.72959659@mail.verizon.net>; from vze2f978@mail.verizon.net on Sun, Jun 03, 2001 at 10:21:40AM -0400 References: <3B1A47F4.72959659@mail.verizon.net> Message-ID: <20010603170755.A23389@pino.selwerd.nl> On 0, Lloyd Hugh Allen wrote: > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html > > Python should be up to the task... > > Anyone have a module lying around for torking with arbitrarily large > numbers (in Python)? No need for a module in Python, it has long integers itself: >>> 1000000000000000000000000L 1000000000000000000000000L The problem here of course isn't Python or long integers, but an algorithm that doesn't take time measured in ages of the universe... I'll help you on your way: 2 is not a factor in any of the numbers. So now you have one fewer prime to check! ;-) -- Remco Gerlich From arcege@speakeasy.net Sun Jun 3 16:12:04 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sun, 3 Jun 2001 11:12:04 -0400 (EDT) Subject: [Tutor] Saving and loading data to/from files In-Reply-To: from "Daryl G" at Jun 03, 2001 02:39:22 PM Message-ID: <200106031512.f53FC4k04685@dsl092-074-184.bos1.dsl.speakeasy.net> Daryl G wrote > The %s doesn't quite work right. If a name is shorter than another, then the > positions wont be right in my simple table. I guess I have to see if that > center() method will work for me. You need to put the width/length specifies in (just like with C). > example > LastName FirstName Phone# > Stephanopolis George 900-856-2992 > Jo Mary 800-328-6387 > is what I end up getting. For this, the formatting string would be: fmt = '''%(L_Name)-15.15s %(F_Name)-15.15s %(PH_num)s''' Last name ("(L_Name)"), left justified ("-"), 15 characters wide (max and min, "15.15") string ("s"); same for first name; the phone number is an unrestricted string. > Computer Spreadsheet Vomitus. I love that. :) Actually, CSV means "comma-separated values" and it is more complicated than just splitting on a comma: if the data has a comma, then the value is quoted with double-quotes, but what if the value has a double-quote? It is also only a textual format, not a data retrieval system; it is one means used to transfer data between database systems. Usually the first line is the field names. If you're interested, look for "ASV" in the Vaults of Parnassus . -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From rick@niof.net Sun Jun 3 16:14:20 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 3 Jun 2001 11:14:20 -0400 Subject: [Tutor] Saving and loading data to/from files In-Reply-To: ; from gman_95@hotmail.com on Sun, Jun 03, 2001 at 02:39:22PM -0000 References: Message-ID: <20010603111420.A29372@tc.niof.net> On Sun, Jun 03, 2001 at 02:39:22PM -0000, Daryl G wrote: > The %s doesn't quite work right. If a name is shorter than another, > then the positions wont be right in my simple table. I guess I have to > see if that center() method will work for me. > > example > LastName FirstName Phone# > Stephanopolis George 900-856-2992 > Jo Mary 800-328-6387 Use a width modifier with your %s spec. "%-20s" means to left justify using at least 20 columns. Just make sure the width you use is as long as the longest value. You can also use "%-*s" % (width,string) if you want the width to be dynamic, ie, if you scan the list first to determine the maximum lengths. -- Is there any need to prove that this odious perversion of the law is a perpetual cause of hatred, discord, and even social disorder? Look at the United States. There is no country in the world where the law confines itself more rigorously to its proper role, which is to guarantee everyone's liberty and property. Accordingly, there is no country in which the social order seems to rest on a more stable foundation. Nevertheless, even in the United States there are two questions, and only two, which since it was founded, have several times put the political order in danger. And what are these two questions? The question of slavery and that of tariffs, that is, precisely the only two questions concerning which, contrary to the general spirit of this republic, the law has assumed a spoiliative character. Slavery is a violation, sanctioned by law, of the rights of the person. Protective tariffs are a violation, perpetrated by the law, of the right to property; and certainly it is remarkable that in the midst of so many other disputes this twofold legal scourge, a sad heritage from the Old World, should be the only one that can and perhaps will lead to the dissolution of the Union. It is, in fact, impossible to imagine any graver situation in a society than one in which the law becomes an instrument of injustice. And if this fact gives rise to such dreadful consequences in the United States, where it is only exceptional, what must be its consequences in Europe where it is a principle and a system? -- Frédéric Bastiat (1801-1850) Rick Pasotto rickp@telocity.com http://www.niof.net From rob@jam.rr.com Sun Jun 3 16:17:56 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sun, 03 Jun 2001 10:17:56 -0500 Subject: [Tutor] Re: Useless Thanks! References: <3B198806.41D90105@jam.rr.com> <3B198C26.DB1DC306@irtc.net> Message-ID: <3B1A5524.E19E170D@jam.rr.com> Tesla Coil wrote: > > > I've uploaded clippage.py > > Wow, what service! > > > Also, how do you like the new look of the site? > > It's not quite as good as oreilly.com yet, but I > > attack it freshly every few weeks or so these days. > > Think it really bad needs to feature a list of the > "Top Ten Most Useless Python Programmers." > > You know people would really scramble to be able > to put on *that* on their resume! > > Could announce to Tutor that you're planning this and > will give honorable mention at the bottom to the one > who writes the Useless Python Program to grab pages > www.lowerstandard.com/python/uselesspython[1-6].html > and generate the statistics. > > Of course, it'll hafta take into account that it'll > soon have more than six pages to grab from all the > responses resulting of its implementation... > > I'll disqualify myself for having the unfair lead > of having thought it up. . > > Also: Perhaps an icon or something to designate a > Useless contribution is specific to *nix or MS? > > Then you could include in Useless challenges: > "Port an existing Useless Python program to an > OS on which it does not currently operate." I'm forwarding this messge in its entirety to the Tutor List to see if anyone has any thoughts on the general subject. Thanks to your collective generosity and creativity, Useless Python has begun to grow into what I certainly hope is "far from useless" as one reviewer phrased it. What would make it even more handy? I'll certainly add the new challenges suggested to me over the last few days, which seem to be amusing some of you. I've been trying to work on my web programming skills (in Python, of course), and would like to add more interactivity to the site. Aside from coming up with a way for people to upload their own source files and descriptions, I've thought it would be interesting if viewers could vote on the uselessness of any script and/or mark whether they think it's Newbie, Intermediate, Advanced, Guru, or Yoo level. Oh, and as soon as I can figure out where we're keeping our log files, I'll try to make some stats available. It's your site. How do you want it to grow next? Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From rob@jam.rr.com Sun Jun 3 16:22:33 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sun, 03 Jun 2001 10:22:33 -0500 Subject: [Tutor] Saving and loading data to/from files References: <3B1A162C.E897E397@irtc.net> <1A07617500E0@kserver.org> Message-ID: <3B1A5639.5CFA48CB@jam.rr.com> Sheila King wrote: > > I thought it was > > Comma Separated Values > > -- > Sheila King I remember the old days, when we called them comma-delimited files. It took me forever to figure out that's what a .csv file was. Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From pdiaz88@terra.es Sun Jun 3 18:24:36 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Sun, 3 Jun 2001 17:24:36 +0000 Subject: [Tutor] Something to tack on to "Useless Python" challenges In-Reply-To: <3B1A47F4.72959659@mail.verizon.net> References: <3B1A47F4.72959659@mail.verizon.net> Message-ID: <01060317243600.07891@duero> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote: > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html > > Python should be up to the task... > > Anyone have a module lying around for torking with arbitrarily large > numbers (in Python)? MPZ module should do the job, but... This is (in my opinion) the type of job not suited python. A C program would do the same job, faster Cheers Pedro > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor - -- /* * Pedro Diaz Jimenez * pdiaz88@terra.es * pdiaz@acm.asoc.fi.upm.es * * Wanna see how 100000! looks like?: * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000 * * La sabiduria me persigue, pero yo soy mas rapido * * "Las artes marciales son parte de una filosofía, * no deben ser consideradas un arma. Y por eso, * recuerda: No hay nada como un buen revolver" * Les Luthiers, Iniciacion a las Artes Marciales * */ Random quote: - ------------- You feel a whole lot more like you do now than you did when you used to. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7GnLcnu53feEYxlERAkgwAKCrJzqjfYDjUPmIwWVO0tdjqeBnwwCfY+VV t1JfWWNdnmqg6BB8UYnnluQ= =cSmp -----END PGP SIGNATURE----- From rob@jam.rr.com Sun Jun 3 16:40:14 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sun, 03 Jun 2001 10:40:14 -0500 Subject: [Tutor] Something to tack on to "Useless Python" challenges References: <3B1A47F4.72959659@mail.verizon.net> <01060317243600.07891@duero> Message-ID: <3B1A5A5E.D4D5E758@jam.rr.com> Pedro Diaz Jimenez wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote: > > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html > > > > Python should be up to the task... > > > > Anyone have a module lying around for torking with arbitrarily large > > numbers (in Python)? > MPZ module should do the job, but... > This is (in my opinion) the type of job not suited python. A C program would > do the same job, faster > > Cheers > > Pedro > > Almost certainly correct, which would make the Python version pretty Useless. But aside from the pure joy of Uselessness, it would be interesting to go as far as possible using Python for some of these really hairy, advanced tasks. Then we'd have some great examples of Python's current limits, and it would be easier for someone to take the part already written in Python and code the remainder in C. Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From deirdre@deirdre.net Sun Jun 3 17:02:54 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sun, 3 Jun 2001 09:02:54 -0700 Subject: [Tutor] Re: Useless Thanks! In-Reply-To: <3B1A5524.E19E170D@jam.rr.com> References: <3B198806.41D90105@jam.rr.com> <3B198C26.DB1DC306@irtc.net> <3B1A5524.E19E170D@jam.rr.com> Message-ID: > > Think it really bad needs to feature a list of the >> "Top Ten Most Useless Python Programmers." I love this idea! Strangely enough, my own contribution came up on a job interview last week when someone asked about whether I'd written network clients or servers. I pointed out that my example of both had been up on the useless python pages for some time. :) >What would make it even more handy? I'll certainly add the new >challenges suggested to me over the last few days, which seem to be >amusing some of you. I've been trying to work on my web programming >skills (in Python, of course), and would like to add more interactivity >to the site. Aside from coming up with a way for people to upload their >own source files and descriptions, I've thought it would be interesting >if viewers could vote on the uselessness of any script and/or mark >whether they think it's Newbie, Intermediate, Advanced, Guru, or Yoo >level. Oh, and as soon as I can figure out where we're keeping our log >files, I'll try to make some stats available. My dislike of that kind of system is that then there tend to be cliques (like in Advogato, where cliques of people can vote someone up or down). How about someone votes on whether or not the example was useful to them? >It's your site. How do you want it to grow next? But thanks for letting me know what I *really* should do (other than submit it) with my simulation modeling homework examples. After all, the bagel baker example DOES explain why the store might be out of bagels.... -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net Macintosh Developer (seeking work): Will work for Cocoa "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From pdiaz88@terra.es Sun Jun 3 20:13:51 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Sun, 3 Jun 2001 19:13:51 +0000 Subject: Any volunteers ? (was: Re: [Tutor] Something to tack on to "Useless Python" challenges) In-Reply-To: <3B1A5A5E.D4D5E758@jam.rr.com> References: <3B1A47F4.72959659@mail.verizon.net> <01060317243600.07891@duero> <3B1A5A5E.D4D5E758@jam.rr.com> Message-ID: <01060319135100.00334@duero> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Well, you could build a computing module using libgmp in C, and then build the rest of the app in python using that module. (modRSAchallenge ?). Very, very interesting We could do something ala distributed.net, but in python and focusing on the factoring challenge. I would love to work on that project. Any volunteers?. Unfortunatly I have exams on june. What about doing that in july/august? I have cryptographic background, and I'm sure more people on this list have too. Any volunteers? Cheers Pedro On Sunday 03 June 2001 15:40, Rob Andrews wrote: > Pedro Diaz Jimenez wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote: > > > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html > > > > > > Python should be up to the task... > > > > > > Anyone have a module lying around for torking with arbitrarily large > > > numbers (in Python)? > > > > MPZ module should do the job, but... > > This is (in my opinion) the type of job not suited python. A C program > > would do the same job, faster > > > > Cheers > > > > Pedro > > Almost certainly correct, which would make the Python version pretty > Useless. But aside from the pure joy of Uselessness, it would be > interesting to go as far as possible using Python for some of these > really hairy, advanced tasks. Then we'd have some great examples of > Python's current limits, and it would be easier for someone to take the > part already written in Python and code the remainder in C. > > Rob - -- /* * Pedro Diaz Jimenez * pdiaz88@terra.es * pdiaz@acm.asoc.fi.upm.es * * Wanna see how 100000! looks like?: * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000 * * La sabiduria me persigue, pero yo soy mas rapido * * "Las artes marciales son parte de una filosofía, * no deben ser consideradas un arma. Y por eso, * recuerda: No hay nada como un buen revolver" * Les Luthiers, Iniciacion a las Artes Marciales * */ Random quote: - ------------- I bet Einstein turned himself all sorts of colors before he invented the lightbulb. -- Homer Simpson Bart The Genius -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7Gox5nu53feEYxlERAgcdAJ4i/sRDI4S1K9R2mZjFHKGBfkcTjgCgtpZ3 oxsC0QezRkMC7uKy72SyT6w= =7qJK -----END PGP SIGNATURE----- From gozin23@hotmail.com Sun Jun 3 18:17:34 2001 From: gozin23@hotmail.com (Dennis Willis) Date: Sun, 03 Jun 2001 17:17:34 -0000 Subject: [Tutor] Async, RAS Message-ID: Hi, I've discovered Python (just!) and have been given a task with Win RAS in which I have to use it async. I'd like to try implement with Python. Does anyone know of any Python RAS examples I can use as a starting point (or any gotcha's they've already tripped over)? Target OS is W2k. Thanks very much. Dennis Willis _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From lha2@columbia.edu Sun Jun 3 18:18:41 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Sun, 03 Jun 2001 13:18:41 -0400 Subject: [Tutor] Something to tack on to "Useless Python" challenges Message-ID: <3B1A7171.ECBECD98@mail.verizon.net> On 0?, Remco Gerlich wrote: >On 0, Lloyd Hugh Allen wrote: >> http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html >> >> Python should be up to the task... >> >> Anyone have a module lying around for torking with arbitrarily large >> numbers (in Python)? > >No need for a module in Python, it has long integers itself: >>>> 1000000000000000000000000L >1000000000000000000000000L > >The problem here of course isn't Python or long integers, but an algorithm >that doesn't take time measured in ages of the universe... > >I'll help you on your way: 2 is not a factor in any of the numbers. So now >you have one fewer prime to check! ;-) Well, I know that for the first the number, the ones digits of the factors end in either 3 and 3 or 1 and 9, but there are probably another 85 digits to find. My question had my Pascal (and just enough c) background showing through: I had assumed that there was a cap on Long Integers, just a bigger one than with regular (short?) integers. From alan.gauld@bt.com Sun Jun 3 20:44:02 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 20:44:02 +0100 Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F8@mbtlipnt02.btlabs.bt.co.uk> > Alan, you can of course use what i did if you want.... Not me, I was just encouraging the original poster. In fact my time on python tutor duty is likely to diminish to supporting my web tutor coz my publisher just accepted my new book proposal but weith an increased scope from my proposal - including twice as many pages!... I'm about to be a busy bee for a while! Alan G From alan.gauld@bt.com Sun Jun 3 20:54:26 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 20:54:26 +0100 Subject: [Tutor] RE: [book recommendation for Programming Pearls] Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F9@mbtlipnt02.btlabs.bt.co.uk> I second the recommendation for Programming Pearls In act there are 2 books 'PP' and 'More PP' They don't use C much its nearly all awk(altho I haven't seen the latest editions(c1999) I have the late '80s editions. They are mines of gold on anything to do with performant computation and also representation of data and documentation. The chapter on the unix 'spell' program is wonderful! In fact they are all pretty good. Alan G. From alan.gauld@bt.com Sun Jun 3 21:00:34 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 21:00:34 +0100 Subject: [Tutor] Lists... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk> > def intersect_eas(L1, L2): > '''The easiest way for Alan G, requires nested_scopes''' > return filter(lambda x: (x in L2), L1) How does it require nested scopes? lambda and filter are builtin, and x,L1 and L2 are all locals. But I accept its not highly performant - that wasn't part of the original question... ;-) Alan G From scarblac@pino.selwerd.nl Sun Jun 3 21:08:08 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 3 Jun 2001 22:08:08 +0200 Subject: [Tutor] Lists... In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Sun, Jun 03, 2001 at 09:00:34PM +0100 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20010603220808.A24174@pino.selwerd.nl> On 0, alan.gauld@bt.com wrote: > > def intersect_eas(L1, L2): > > '''The easiest way for Alan G, requires nested_scopes''' > > return filter(lambda x: (x in L2), L1) > > How does it require nested scopes? > lambda and filter are builtin, > and x,L1 and L2 are all locals. L1 and L2 are not locals inside the lambda. They're only visible with nested scopes. -- Remco Gerlich From alan.gauld@bt.com Sun Jun 3 21:07:23 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 21:07:23 +0100 Subject: [Tutor] Ok Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FB@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0EC68.CD502730 Content-type: text/plain; charset="ISO-8859-1" Ok, I am going to stick with it, I will say this agian I am a beginer an know nothing about programming, so half the stuff that is sent I will not undersand! Thank you. Richard E Parks 2 RickyP1@frontiernet.net Good. Now it might help if you went into posting mode instead of reading(BTW you can cut the volume down by getting the digest - that wraps about 12-15 messages into a single one. Its an option on the tutor mail web page. How are you trying to learn? Are you using a book or online tutor? If so which? How far thru' have you gotten. This list will try to answer beginner questions of any standard(if thats not a contradiction in terms!) Have fun, Alan G ------_=_NextPart_001_01C0EC68.CD502730 Content-type: text/html; charset="ISO-8859-1"
    Ok, I am going to stick with it, I will say this agian I am a beginer an know nothing about programming, so half the stuff that is sent I will not undersand! Thank you.
                                        Richard E Parks 2
                                        RickyP1@frontiernet.net
 
Good. Now it might help if you went into posting mode
instead of reading(BTW you can cut the volume down by
getting the digest - that wraps about 12-15 messages
into a single one. Its an option on the tutor mail
web page.    
 
How are you trying to learn? Are you using a book or online tutor?
If so which? How far thru' have you gotten. This list will try to answer
beginner questions of any standard(if thats not a contradiction in terms!)
 
Have fun,
 
Alan G
------_=_NextPart_001_01C0EC68.CD502730-- From gman_95@hotmail.com Sun Jun 3 21:20:03 2001 From: gman_95@hotmail.com (Daryl G) Date: Sun, 03 Jun 2001 20:20:03 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: AHA! That was it, though I did have to do it a little differently. The way you showed didn't seem to work with lists, so I just converted each individual part of a list into a String and then it worked for i in range(total): LN=L_Name[i] FN=F_Name[i] PH=PH_num[i] print"%-15.15s %-15.15s %-s" % (LN, FN, PH) Thanks Again! >From: "Michael P. Reilly" >Reply-To: arcege@speakeasy.net >To: gman_95@hotmail.com (Daryl G) >CC: tutor@python.org >Subject: Re: [Tutor] Saving and loading data to/from files >Date: Sun, 3 Jun 2001 11:12:04 -0400 (EDT) > >Daryl G wrote > > The %s doesn't quite work right. If a name is shorter than another, then >the > > positions wont be right in my simple table. I guess I have to see if >that > > center() method will work for me. > >You need to put the width/length specifies in (just like with C). > > > example > > LastName FirstName Phone# > > Stephanopolis George 900-856-2992 > > Jo Mary 800-328-6387 > > is what I end up getting. > >For this, the formatting string would be: >fmt = '''%(L_Name)-15.15s %(F_Name)-15.15s %(PH_num)s''' > >Last name ("(L_Name)"), left justified ("-"), 15 characters wide (max >and min, "15.15") string ("s"); same for first name; the phone number >is an unrestricted string. > > > Computer Spreadsheet Vomitus. I love that. :) > >Actually, CSV means "comma-separated values" and it is more complicated >than just splitting on a comma: if the data has a comma, then the value >is quoted with double-quotes, but what if the value has a double-quote? >It is also only a textual format, not a data retrieval system; it is >one means used to transfer data between database systems. Usually the >first line is the field names. If you're interested, look for "ASV" >in the Vaults of Parnassus . > > -Arcege > >-- >+----------------------------------+-----------------------------------+ >| Michael P. Reilly | arcege@speakeasy.net | _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From alan.gauld@bt.com Sun Jun 3 21:16:29 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 21:16:29 +0100 Subject: [Tutor] Prompt Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FC@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0EC6A.13018890 Content-type: text/plain; charset="iso-8859-1" Thank you all for the suport. My bigest problem right now is getiing the software to run. I downloaded python 2.0 Windows Installer from the python.org web site. I am still having a problem with the prompt screen closing too fast I can even read what is says! This seems to be common for beginners on windoze. Try running the Python GUI(IDLE) instead of Python. Or if you got the ActiveState version run Pythonwin. Alternatively start a DOS box session and type python at the C:> prompt. That way the DOS box stays put after your program runs so you see the output! Somebody should really write up in detail how to start a program (and the interpreter) for non command-line users.... I've been meaning to add it to my tutor for months! HTH, Alan g ------_=_NextPart_001_01C0EC6A.13018890 Content-type: text/html; charset="iso-8859-1"
Thank you all for the suport. My bigest problem right now is getiing the software to run. I downloaded python 2.0 Windows Installer from the python.org web site. I am still having a problem  with the prompt screen closing too fast I can even read what is says!   
 
This seems to be common for beginners on windoze.
Try running the Python GUI(IDLE) instead of Python.
Or if you got the ActiveState version run Pythonwin.
 
Alternatively start a DOS box session and type python
at the C:> prompt. That way the DOS box stays put
after your program runs so you see the output!
 
Somebody should really write up in detail how to start
a program (and the interpreter) for non command-line
users.... I've been meaning to add it to my tutor
for months!
 
HTH,
 
Alan g
 
 
------_=_NextPart_001_01C0EC6A.13018890-- From alan.gauld@bt.com Sun Jun 3 21:30:47 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Sun, 3 Jun 2001 21:30:47 +0100 Subject: [Tutor] Saving and loading data to/from files Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FD@mbtlipnt02.btlabs.bt.co.uk> > A "csv" file is a file where all the fields as separated by > commas. It's... > I'm not quite sure what each of the letters stand for > though. Comma Separated... Vormat? Values... Alan G From arcege@speakeasy.net Sun Jun 3 22:09:07 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT) Subject: [Tutor] Saving and loading data to/from files In-Reply-To: from "Daryl G" at Jun 03, 2001 08:20:03 PM Message-ID: <200106032109.f53L97a01253@dsl092-074-184.bos1.dsl.speakeasy.net> Daryl G wrote > That was it, though I did have to do it a little differently. > The way you showed didn't seem to work with lists, so I just converted each > individual part of a list into a String and then it worked > > for i in range(total): > LN=L_Name[i] > FN=F_Name[i] > PH=PH_num[i] > print"%-15.15s %-15.15s %-s" % (LN, FN, PH) Sorry, I hadn't quite gotten that they were lists (I haven't really been feeling "with it" lately). You might find it easier to keep things together. Create tuples with the information, then arrays of those tuples. NameInfo = [ ('Guido', 'van Rossum', '703-555-1234'), ('Eric', 'Idle', '212-555-5346'), ] for i in range(len(NameInfo)): (FN, LN, PH) = NameInfo[i] print "%-15.15s %-15.15s %s" % (LN, FN, PH) This will allow for keeping things together later, and for better looping structures: `for (FN, LN, PH) in NameInfo:' Alternatively, you could use a dictionary for records of "named" fields: NameInfo = [ {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'}, {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}, ] for record in NameInfo: print "%-15.15(last)s %-15.15(first)s %(phone)s" % record Or maybe make a class: class Record: def __init__(self, first, last, phone): self.first, self.last, self.phone = first, last, phone def __str__(self): return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone) NameInfo = [ Record('Guido', 'van Rossum', '703-555-1234'), Record('Eric', 'Idle', '212-555-5346'), ] for record in NameInfo: print record There are a lot of choices for you, but separate lists for each field probably isn't a good one. :) (Incidently, the pickle and shelve modules handle all these structures) -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From tescoil@irtc.net Sun Jun 3 23:13:47 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sun, 03 Jun 2001 17:13:47 -0500 Subject: [Tutor] Random Words. Message-ID: <3B1AB69B.DB3C37E1@irtc.net> Way to read the file more efficiently if it were larger? (/usr/share/dict/words has 45,424 entries; I also have /usr/dict/words with 79,339 entries, and /usr/dict/words.ott with 172,822). Where would be preferable to filter out undesired words? Remove them from the list before choosing, or, reject them if chosen and replace them? I'm inclined toward the latter, but wonder if that's best when there's fair chance of rejection, say, refusing len(words) <=3 and >=9. And just interested in any different approach... #!/usr/bin/env python # randword.py -- Quick and Dirty # return a list of random words. import random def readfile(lexfile): file = open(lexfile) lexlist = file.readlines() file.close() return lexlist def choosewords(lexlist): randwords = [] entries = len(lexlist) for iteration in range(20): word = random.randint(0, entries) randwords.append(wordlist[word]) return randwords wordsource = '/usr/share/dict/words' wordlist = readfile(wordsource) randlist = choosewords(wordlist) for word in randlist: print word, From tescoil@irtc.net Sun Jun 3 23:15:29 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sun, 03 Jun 2001 17:15:29 -0500 Subject: [Tutor] Saving and loading data to/from files References: <3B1A162C.E897E397@irtc.net> <1A07617500E0@kserver.org> Message-ID: <3B1AB701.38A6FCE1@irtc.net> On 3 Jun 2001, Sheila King replied: >> Comma Separated Variable, or, >> Computer Spreadsheet Vomitus, >> depending on who you ask... > > I thought it was > > Comma Separated Values That's the real "depending on who you ask." I'd say "Comma Separated Values" is more popular and makes more sense, but "Comma Separated Variable" was the answer received first time I asked, and you'll get plenty of hits searching the net for either phrase. From rick@niof.net Sun Jun 3 23:48:50 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 3 Jun 2001 18:48:50 -0400 Subject: [Tutor] Random Words. In-Reply-To: <3B1AB69B.DB3C37E1@irtc.net>; from tescoil@irtc.net on Sun, Jun 03, 2001 at 05:13:47PM -0500 References: <3B1AB69B.DB3C37E1@irtc.net> Message-ID: <20010603184850.B29372@tc.niof.net> How about: import random,string,os stat = os.stat('/usr/share/dict/words') # the filesize if the 7th element of the array flen = stat[6] f = open('/usr/share/dict/words') words = [] while len(words) < 5: # seek to a random offset in the file f.seek(int(random.random() * flen)) # do a single read with sufficient characters chars = f.read(50) # split it on white space wrds = string.split(chars) # the first element may be only a partial word so use the second # you can also make other tests on the word here if len(wrds[1]) > 3 and len(wrds[1]) < 9: words.append(wrds[1]) print words This uses minimal memory and I suspect is about as fast as you're going to get. On Sun, Jun 03, 2001 at 05:13:47PM -0500, Tesla Coil wrote: > Way to read the file more efficiently if it were > larger? (/usr/share/dict/words has 45,424 entries; > I also have /usr/dict/words with 79,339 entries, > and /usr/dict/words.ott with 172,822). > > Where would be preferable to filter out undesired > words? Remove them from the list before choosing, > or, reject them if chosen and replace them? I'm > inclined toward the latter, but wonder if that's > best when there's fair chance of rejection, say, > refusing len(words) <=3 and >=9. > > And just interested in any different approach... > > #!/usr/bin/env python > # randword.py -- Quick and Dirty > # return a list of random words. > import random > > def readfile(lexfile): > file = open(lexfile) > lexlist = file.readlines() > file.close() > return lexlist > > def choosewords(lexlist): > randwords = [] > entries = len(lexlist) > for iteration in range(20): > word = random.randint(0, entries) > randwords.append(wordlist[word]) > return randwords > > wordsource = '/usr/share/dict/words' > wordlist = readfile(wordsource) > randlist = choosewords(wordlist) > for word in randlist: print word, > -- When under the pretext of fraternity, the legal code imposes mutual sacrifices on the citizens, human nature is not thereby abrogated. Everyone will then direct his efforts toward contributing little to, and taking much from, the common fund of sacrifices. Now, is it the most unfortunate who gains from this struggle? Certainly not, but rather the most influential and calculating. -- Frédéric Bastiat (1801-1850) Rick Pasotto rickp@telocity.com http://www.niof.net From gman_95@hotmail.com Mon Jun 4 00:05:11 2001 From: gman_95@hotmail.com (Daryl G) Date: Sun, 03 Jun 2001 23:05:11 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Whoever is "with it" on a Sunday? ;) I originally had it set up as a dictionary, but when I was displaying them, it wasn't coming out right and I see why now. I will eventually use classes, I'm just getting the basic functionality down first. I was trying the dictionary example in a seperate script, but I get a traceback error File "C:\Python20\dict.py", line 7, in ? print "%-15.15(last)s %-15.15(first)s %(phone)s" % record ValueError: unsupported format character '(' (0x28) Python ver 2.0 The tuple example works. I like this one, but tuples aren't mutable, thats why I -reluctantly- chose lists when I couldn't get the dictionary to display how I wanted to. That way if say a phone number changes, I just need to edit the phone number and not have to delete that record and reenter it all in But I'll implement that later Cool! Daryl >From: "Michael P. Reilly" >Reply-To: arcege@speakeasy.net >To: gman_95@hotmail.com (Daryl G) >CC: tutor@python.org >Subject: Re: [Tutor] Saving and loading data to/from files >Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT) > >Daryl G wrote > > That was it, though I did have to do it a little differently. > > The way you showed didn't seem to work with lists, so I just converted >each > > individual part of a list into a String and then it worked > > > > for i in range(total): > > LN=L_Name[i] > > FN=F_Name[i] > > PH=PH_num[i] > > print"%-15.15s %-15.15s %-s" % (LN, FN, PH) > >Sorry, I hadn't quite gotten that they were lists (I haven't really been >feeling "with it" lately). > >You might find it easier to keep things together. Create tuples with >the information, then arrays of those tuples. >NameInfo = [ > ('Guido', 'van Rossum', '703-555-1234'), > ('Eric', 'Idle', '212-555-5346'), >] >for i in range(len(NameInfo)): > (FN, LN, PH) = NameInfo[i] > print "%-15.15s %-15.15s %s" % (LN, FN, PH) > >This will allow for keeping things together later, and for better >looping structures: `for (FN, LN, PH) in NameInfo:' > > >Alternatively, you could use a dictionary for records of "named" fields: >NameInfo = [ > {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'}, > {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}, >] >for record in NameInfo: > print "%-15.15(last)s %-15.15(first)s %(phone)s" % record > > >Or maybe make a class: >class Record: > def __init__(self, first, last, phone): > self.first, self.last, self.phone = first, last, phone > def __str__(self): > return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone) >NameInfo = [ > Record('Guido', 'van Rossum', '703-555-1234'), > Record('Eric', 'Idle', '212-555-5346'), >] >for record in NameInfo: > print record > >There are a lot of choices for you, but separate lists for each field >probably isn't a good one. :) (Incidently, the pickle and shelve modules >handle all these structures) > > -Arcege > >-- >+----------------------------------+-----------------------------------+ >| Michael P. Reilly | arcege@speakeasy.net | _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From rick@niof.net Mon Jun 4 00:20:53 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 3 Jun 2001 19:20:53 -0400 Subject: [Tutor] Saving and loading data to/from files In-Reply-To: ; from gman_95@hotmail.com on Sun, Jun 03, 2001 at 11:05:11PM -0000 References: Message-ID: <20010603192053.C29372@tc.niof.net> On Sun, Jun 03, 2001 at 11:05:11PM -0000, Daryl G wrote: > > I was trying the dictionary example in a seperate script, but I get a > traceback error > > File "C:\Python20\dict.py", line 7, in ? > print "%-15.15(last)s %-15.15(first)s %(phone)s" % record > ValueError: unsupported format character '(' (0x28) Try: print "%(last)-15.15s %(first)-15.15s %(phone)s" % record -- When under the pretext of fraternity, the legal code imposes mutual sacrifices on the citizens, human nature is not thereby abrogated. Everyone will then direct his efforts toward contributing little to, and taking much from, the common fund of sacrifices. Now, is it the most unfortunate who gains from this struggle? Certainly not, but rather the most influential and calculating. -- Frédéric Bastiat (1801-1850) Rick Pasotto rickp@telocity.com http://www.niof.net From tescoil@irtc.net Mon Jun 4 01:35:52 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sun, 03 Jun 2001 19:35:52 -0500 Subject: [Tutor] Random Words. References: <3B1AB69B.DB3C37E1@irtc.net> <20010603184850.B29372@tc.niof.net> Message-ID: <3B1AD7E8.5CF59DFF@irtc.net> On 3 Jun 2001, Rick Pasotto replied: > This uses minimal memory and I suspect is > about as fast as you're going to get. That completely smokes! I narrowed the criteria to only words of 8 characters, tried it on a list of around 235,000 entries--it still doesn't blink. From gman_95@hotmail.com Mon Jun 4 02:06:07 2001 From: gman_95@hotmail.com (Daryl G) Date: Mon, 04 Jun 2001 01:06:07 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Ok, I figured out the dictionary problem Change the print statement for record in NameInfo: print "%-15.15s %-15.15s %s" % (record['first'], record['last'], record['phone']) now I don't get that error, however I am having difficulty in figuring out how to add data to the dictionary. This seems to be a sequence directory because of the brackets, correct? Plus in some of my attempts I get a TypeError loop non-sequence Accessing the values inside is different then a non-sequence directionary. Any insight? Daryl >From: "Michael P. Reilly" >Reply-To: arcege@speakeasy.net >To: gman_95@hotmail.com (Daryl G) >CC: tutor@python.org >Subject: Re: [Tutor] Saving and loading data to/from files >Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT) > >Daryl G wrote > > That was it, though I did have to do it a little differently. > > The way you showed didn't seem to work with lists, so I just converted >each > > individual part of a list into a String and then it worked > > > > for i in range(total): > > LN=L_Name[i] > > FN=F_Name[i] > > PH=PH_num[i] > > print"%-15.15s %-15.15s %-s" % (LN, FN, PH) > >Sorry, I hadn't quite gotten that they were lists (I haven't really been >feeling "with it" lately). > >You might find it easier to keep things together. Create tuples with >the information, then arrays of those tuples. >NameInfo = [ > ('Guido', 'van Rossum', '703-555-1234'), > ('Eric', 'Idle', '212-555-5346'), >] >for i in range(len(NameInfo)): > (FN, LN, PH) = NameInfo[i] > print "%-15.15s %-15.15s %s" % (LN, FN, PH) > >This will allow for keeping things together later, and for better >looping structures: `for (FN, LN, PH) in NameInfo:' > > >Alternatively, you could use a dictionary for records of "named" fields: >NameInfo = [ > {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'}, > {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}, >] >for record in NameInfo: > print "%-15.15(last)s %-15.15(first)s %(phone)s" % record > > >Or maybe make a class: >class Record: > def __init__(self, first, last, phone): > self.first, self.last, self.phone = first, last, phone > def __str__(self): > return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone) >NameInfo = [ > Record('Guido', 'van Rossum', '703-555-1234'), > Record('Eric', 'Idle', '212-555-5346'), >] >for record in NameInfo: > print record > >There are a lot of choices for you, but separate lists for each field >probably isn't a good one. :) (Incidently, the pickle and shelve modules >handle all these structures) > > -Arcege > >-- >+----------------------------------+-----------------------------------+ >| Michael P. Reilly | arcege@speakeasy.net | _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From sarnold@earthling.net Mon Jun 4 02:44:03 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Sun, 3 Jun 2001 18:44:03 -0700 Subject: [Tutor] command prompt HOWTO Message-ID: <20010604014404.36F841F62A@shiva.arnolds.bogus> Howdy: I have (semi-coherent rambling) mini-HOWTO for running Python programs at the DOS and Linux command prompts. It's got some environment stuff, examples, etc. If I get some questions/feedback/flames I'll try and make the appropriate changes. It's kinda long; should I post it to the list anyway? Steve From GADGILP@INFOTECH.ICICI.com Mon Jun 4 04:47:55 2001 From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Mon, 4 Jun 2001 09:17:55 +0530 Subject: [Tutor] Re: [Python-Help] a number and control char stored in a single char. ! Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D44@ICICIBACK3> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0ECA9.238B6520 Content-Type: text/plain; charset="iso-8859-1" hello, daniel, u r a life saver! Thanks. well what i meant when i said, i cant post to tutor list, is that, I was posting from cybercafe, couldn't change sender's addr to my subscribed id. I thought non subscribers can't post. /regards prasad > -----Original Message----- > From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu] > Sent: Saturday, June 02, 2001 11:25 AM > Cc: help@python.org; tutor@python.org > Subject: [Tutor] Re: [Python-Help] a number and control char > stored in a > single char. ! > > > On Fri, 1 Jun 2001, kaha aham wrote: > > > > I am running & capturing screen output of a command using > os.popen as > > helped by tuto@python.org ppl. However the value i capture which > > should be a number like something like 22345 is displayed as > > '22345\012' > > Yes, this means that what you're getting back is the string "21345" > followed by the newline, '\012'. What you'll need to do is convert it > with the int() function. > > > > > I need to numerically compare this value later in program. I tried > > slicing it to remove the last control char using var[:-1], > on which it > > prints []. I then trid using len(), it tells size as 1 char. I tried > > printing just 1st char using var[0], and it shows '22345\012' > > Ah! You had the right idea: what you'll want to do is: > > var[0][:-1] > > instead. You want to get all but the last character from var[0], your > first line of the output. This is probably what was > preventing you from > converting to integer. Try int()'ing with var[0][:-1], and > you should be > ok. But if you're converting with int(), you don't need to > strip out the > newline character; int() knows how to deal with it already. > > > Let's look at what happened before... I'm guessing that when you used > os.popen(), you used the readlines() method to get at all the lines of > output. What this means is that "var" stands for all the > lines of input, > and "var[0]" stands for the first line. However, "var[:-1]" > stands for > all but the last line --- but if your output only consists of > one line, > that means you'll get the empty list, []. That should > explain the weird > error messages. > > > > That's baffling me. How can it put all that number and > control char in > > 1 char. I currently can't post to tutor maillist as I did earlier. > > Hmmm... that's strange! Try posting your question again; > perhaps the mail > host was down. In the meantime, I'll forward your message to > tutor@python.org. > > I just checked, and from what I can tell, you're not subscribed to the > tutor list yet. You'll probably need to subscribe to post to > tutor. You > can subscribe here: > > http://mail.python.org/mailman/listinfo/tutor > > > If you run into difficulties again, feel free to email again. > I'll talk > to you later! > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > . ------_=_NextPart_001_01C0ECA9.238B6520 Content-Type: text/html; charset="iso-8859-1" RE: [Tutor] Re: [Python-Help] a number and control char stored in a single char. !

hello,

daniel, u r a life saver! Thanks.

well what i meant when i said, i cant post to tutor list, is that, I was posting
from cybercafe, couldn't change sender's addr to my subscribed
id. I thought non subscribers can't post.

/regards
prasad


> -----Original Message-----
> From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
> Sent: Saturday, June 02, 2001 11:25 AM
> Cc: help@python.org; tutor@python.org
> Subject: [Tutor] Re: [Python-Help] a number and control char
> stored in a
> single char. !
>
>
> On Fri, 1 Jun 2001, kaha aham wrote:
>
>
> > I am running & capturing screen output of a command using
> os.popen as
> > helped by tuto@python.org ppl. However the value i capture which
> > should be a number like something like 22345 is displayed as
> > '22345\012'
>
> Yes, this means that what you're getting back is the string "21345"
> followed by the newline, '\012'.  What you'll need to do is convert it
> with the int() function.
>
>
>
> > I need to numerically compare this value later in program. I tried
> > slicing it to remove the last control char using var[:-1],
> on which it
> > prints []. I then trid using len(), it tells size as 1 char. I tried
> > printing just 1st char using var[0], and it shows '22345\012'
>
> Ah!  You had the right idea: what you'll want to do is:
>
>     var[0][:-1]
>
> instead.  You want to get all but the last character from var[0], your
> first line of the output.  This is probably what was
> preventing you from
> converting to integer.  Try int()'ing with var[0][:-1], and
> you should be
> ok.  But if you're converting with int(), you don't need to
> strip out the
> newline character; int() knows how to deal with it already.
>
>
> Let's look at what happened before... I'm guessing that when you used
> os.popen(), you used the readlines() method to get at all the lines of
> output.  What this means is that "var" stands for all the
> lines of input,
> and "var[0]" stands for the first line.  However, "var[:-1]"
> stands for
> all but the last line --- but if your output only consists of
> one line,
> that means you'll get the empty list, [].  That should
> explain the weird
> error messages.
>
>
> > That's baffling me. How can it put all that number and
> control char in
> > 1 char. I currently can't post to tutor maillist as I did earlier.
>
> Hmmm... that's strange!  Try posting your question again;
> perhaps the mail
> host was down.  In the meantime, I'll forward your message to
> tutor@python.org.
>
> I just checked, and from what I can tell, you're not subscribed to the
> tutor list yet.  You'll probably need to subscribe to post to
> tutor.  You
> can subscribe here:
>
>     http://mail.python.org/mailman/listinfo/tutor
>
>
> If you run into difficulties again, feel free to email again.
>  I'll talk
> to you later!
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


..

------_=_NextPart_001_01C0ECA9.238B6520-- From r.b.rigilink@chello.nl Mon Jun 4 07:40:39 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Mon, 04 Jun 2001 08:40:39 +0200 Subject: [Tutor] Saving and loading data to/from files References: Message-ID: <3B1B2D67.7EF35199@chello.nl> Hi Daryl, Daryl G wrote: > > Ok, I figured out the dictionary problem > Change the print statement > for record in NameInfo: > > print "%-15.15s %-15.15s %s" % (record['first'], record['last'], > record['phone']) > > now I don't get that error, however I am having difficulty in figuring out > how to add data to the dictionary. > This seems to be a sequence directory because of the brackets, correct? Plus > in some of my attempts I get a TypeError loop non-sequence > Accessing the values inside is different then a non-sequence directionary. > Any insight? > NameInfo is a list (sequence). Each element in this list is a dictionary. The trick is to know when you are dealing with the list, and when you're dealing with an item (a dictionary in this case) in the list. Just some examples to help you on your way: Here a two-element list of dictionaries is build NameInfo = [ {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'}, {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}] You can access a list-element by indexing with an integer, i.e the first element with: print "%(first)-15.15s %(last)-15.15s %s" % NameInfo[0] Guido van Rossum 703-555-1234 (Maybe you're surprised that the first item in a list has index 0. Think of it as an offset) You can add a new element using something like: NameInfo.append({'first':'Basil', 'last':'Fawlty', 'phone':'111-222-33333'} You can change an element by replacing it with a new dictionary NameInfo[0] = {'first':'Tim', 'last':'Peters', 'phone':'333-111-22222'} You can also address items inside each dictionary, for example print NameInfo[1]['first'] Eric (i.e. get the second item in the list and from that item het the value of 'first') Use that to add some info to a dict NameInfo[2]['birth'] = '01 Apr 1933' # Date of birth for Basil Fawlty The summary: Lists are indexed with integers. Dictionaries are indexed with a key, which can be pretty much anything List items are added using the_list.append(item) Dict items are changed/added using the_dict[key] = value if you have a list of dicts, you can access an item in a dict with value = alist[index][key] which is pretty much equivalent to record = alist[index] value = record[key] Hope this helps, Roeland Rengelink -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From alan.gauld@bt.com Mon Jun 4 11:17:17 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 4 Jun 2001 11:17:17 +0100 Subject: [Tutor] Lists... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FE@mbtlipnt02.btlabs.bt.co.uk> > > > def intersect_eas(L1, L2): > > > '''The easiest way for Alan G, requires nested_scopes''' > > > return filter(lambda x: (x in L2), L1) > > > > How does it require nested scopes? > L1 and L2 are not locals inside the lambda. They're only > visible with nested scopes. Ah, of course. Although the lambda definition is inside the function the call to it isn't. Rats! Alan G From alan.gauld@bt.com Mon Jun 4 11:38:02 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 4 Jun 2001 11:38:02 +0100 Subject: [Tutor] Lists... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FF@mbtlipnt02.btlabs.bt.co.uk> > > def intersect_eas(L1, L2): > > '''The easiest way for Alan G, requires nested_scopes''' > > return filter(lambda x: (x in L2), L1) OK a version not requiring nested scopes... def intersect(L1,L2): return filter(lambda x,y=L2:(x in y), L1) Still not fast tho'... :-) Alan g. PS I needed something similar for a web page that has to run on py 1.5.1 so nested scopes were no use to me... From gman_95@hotmail.com Mon Jun 4 14:07:03 2001 From: gman_95@hotmail.com (Daryl G) Date: Mon, 04 Jun 2001 13:07:03 -0000 Subject: [Tutor] Saving and loading data to/from files Message-ID: Thanks Roeland! Thats what I needed. I should have thought of that; NameInfo[0]['first']. Ah well, I was working on this part late last night anyway Thanks for everyones help! Daryl >From: Roeland Rengelink >To: Daryl G >CC: tutor@python.org >Subject: Re: [Tutor] Saving and loading data to/from files >Date: Mon, 04 Jun 2001 08:40:39 +0200 > >Hi Daryl, > >Daryl G wrote: > > > > Ok, I figured out the dictionary problem > > Change the print statement > > for record in NameInfo: > > > > print "%-15.15s %-15.15s %s" % (record['first'], record['last'], > > record['phone']) > > > > now I don't get that error, however I am having difficulty in figuring >out > > how to add data to the dictionary. > > This seems to be a sequence directory because of the brackets, correct? >Plus > > in some of my attempts I get a TypeError loop non-sequence > > Accessing the values inside is different then a non-sequence >directionary. > > Any insight? > > > >NameInfo is a list (sequence). Each element in this list is a >dictionary. > >The trick is to know when you are dealing with the list, and when you're >dealing with an item (a dictionary in this case) in the list. Just some >examples to help you on your way: > >Here a two-element list of dictionaries is build > >NameInfo = [ > {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'}, > {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}] > >You can access a list-element by indexing with an integer, i.e the first >element with: > >print "%(first)-15.15s %(last)-15.15s %s" % NameInfo[0] >Guido van Rossum 703-555-1234 > >(Maybe you're surprised that the first item in a list has index 0. Think >of it as an offset) > >You can add a new element using something like: > >NameInfo.append({'first':'Basil', 'last':'Fawlty', >'phone':'111-222-33333'} > >You can change an element by replacing it with a new dictionary > >NameInfo[0] = {'first':'Tim', 'last':'Peters', 'phone':'333-111-22222'} > >You can also address items inside each dictionary, for example > >print NameInfo[1]['first'] >Eric > >(i.e. get the second item in the list and from that item het the value >of 'first') > >Use that to add some info to a dict > >NameInfo[2]['birth'] = '01 Apr 1933' # Date of birth for Basil Fawlty > > >The summary: > >Lists are indexed with integers. >Dictionaries are indexed with a key, which can be pretty much anything > >List items are added using the_list.append(item) >Dict items are changed/added using the_dict[key] = value > >if you have a list of dicts, you can access an item in a dict with > >value = alist[index][key] > >which is pretty much equivalent to > >record = alist[index] >value = record[key] > > >Hope this helps, > >Roeland Rengelink >-- >r.b.rigilink@chello.nl > >"Half of what I say is nonsense. Unfortunately I don't know which half" _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From GBunting864@Worldsavings.com Mon Jun 4 20:23:43 2001 From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x)) Date: Mon, 4 Jun 2001 14:23:43 -0500 Subject: [Tutor] ActivePython Message-ID: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com> What is the difference between ActivePython and the regular python from www.python.org for windows? Thanks Glen ***************************************************************************** If you are not the intended recipient of this e-mail, please notify the sender immediately. The contents of this e-mail do not amend any existing disclosures or agreements unless expressly stated. ***************************************************************************** From hall@phyast.nhn.ou.edu Mon Jun 4 20:25:38 2001 From: hall@phyast.nhn.ou.edu (Isaac Hall) Date: Mon, 04 Jun 2001 14:25:38 -0500 Subject: [Tutor] small (I hope) questions Message-ID: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu> first, let me introduce myself a little as I am new to this list (but I may well be widely known as the guy with all the dumb questions soon...I hope not) Ive just begun working with Python and Tkinter in physics applications, and Im getting stuck in some fairly minor aspects of this. I have previously only programmed in C/C++. anyway my question(s) are: a) I am trying to produce a pie chart of just random numbers in a list to get started with this, however Im confused as to how to call up a canvas, and draw the chart. b) in addition to the pie chart, I also need to put these numbers in a table (which I have figured out, however I would like to be able to create this so that the pie chart comes up first, and then clicking on the pie chart will display the table. If anyone can help it would be greatly appreciated...my main problem is in which commands do this, and their syntax, which I am not yet used to...the logic part of this, I am so far ok with. From dsh8290@rit.edu Mon Jun 4 20:37:53 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 4 Jun 2001 15:37:53 -0400 Subject: [Tutor] ActivePython In-Reply-To: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com>; from GBunting864@worldsavings.com on Mon, Jun 04, 2001 at 02:23:43PM -0500 References: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com> Message-ID: <20010604153753.C11144@harmony.cs.rit.edu> On Mon, Jun 04, 2001 at 02:23:43PM -0500, Bunting, Glen, IG (x) wrote: | What is the difference between ActivePython and the regular python from | www.python.org for windows? ActivePython comes with the win32all extensions and an IDE. "Regular" python is just the interpreter, and IDLE bundled up with it (a simplistic IDE). Personally, I use the interpreter shipped with cygwin in conjunction with (g)vim. -D From mikebacks@yahoo.com Mon Jun 4 20:48:21 2001 From: mikebacks@yahoo.com (Michael Bacayo) Date: Mon, 4 Jun 2001 12:48:21 -0700 (PDT) Subject: [Tutor] Help with Process Commands Message-ID: <20010604194821.55492.qmail@web10402.mail.yahoo.com> I want to learn how to use system(), spawnv(), and spawnve() the right way. When I use this in a program of mine, these commands seem to be inconsistent in the manner that the arguments are sent to the called program. Sometimes, you need to include the arguments in the list or tuple with spaces before and after the "'s and sometimes it's not need. The arguments are not passed correctly to the called program if not written a certain way. Thanks! __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From rob@jam.rr.com Mon Jun 4 20:56:21 2001 From: rob@jam.rr.com (Rob Andrews) Date: Mon, 4 Jun 2001 14:56:21 -0500 Subject: [Tutor] ActivePython References: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com> Message-ID: <002901c0ed30$6da1b060$de00a8c0@planhouse5> > What is the difference between ActivePython and the regular python from > www.python.org for windows? > > Thanks > > Glen > I'm sure someone can answer this better, but ActivePython comes with a slightly different bundle including PythonWin, which is similar to IDLE. For most purposes, there appears to be little difference, and I like both. Rob Useless Python It's not just for breakfast anymore! http://www.lowerstandard.com/python/index.html From ak@silmarill.org Mon Jun 4 21:04:56 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Mon, 04 Jun 2001 16:04:56 -0400 Subject: [Tutor] Help with Process Commands In-Reply-To: <"from mikebacks"@yahoo.com> References: <20010604194821.55492.qmail@web10402.mail.yahoo.com> Message-ID: <20010604160456.A19445@sill.silmarill.org> On Mon, Jun 04, 2001 at 12:48:21PM -0700, Michael Bacayo wrote: > I want to learn how to use system(), spawnv(), and > spawnve() the right way. When I use this in a program > of mine, these commands seem to be inconsistent in the > manner that the arguments are sent to the called > program. Sometimes, you need to include the arguments > in the list or tuple with spaces before and after the > "'s and sometimes it's not need. The arguments are not > passed correctly to the called program if not written > a certain way. > > Thanks! Here's the os.system() syntax: os.system('ls -al') or os.system('ls -a -l') IOW, everything inside quotes is passed on to the shell for processing, so you just use the command the way you'd type it in the shell. Sometimes you will need to do this: args = ' -al' cmd = 'ls' os.system(cmd + args) or args = [' -a',' -l'] cmd = 'ls' os.system(cmd + args[0] + args[1]) -- Shine on you crazy diamond - Roger From curtis.larsen@Covance.Com Mon Jun 4 22:10:36 2001 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Mon, 04 Jun 2001 16:10:36 -0500 Subject: [Tutor] De-CSV-ing? Message-ID: What would be the easiest (or simplest) way to convert a line from a CSV file into a list or tuple? Sure, you can use ".split(',')" to break the line into a list -- that's the easy part. For example, if each read line in a CSV file were represented by string "s": s = "1,2,3,5.5,3.95,dog,cat,ferret" s1 = s.split(",") s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret'] That's great as far as it goes -- you have each value as a uniquely-addressable item again. But is there an easy way to convert the numbers-as-strings field values back to being numbers? Also, how would you handle a CSV file where the strings were actually delimited by (double or single) quotes? (e.g. the record would look like: 1,2,3,"dog","cat","ferret",7.95 ) Do you have to loop through each value in each line, or is there an easier/faster conversion approach? Thanks! Curtis ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that we can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From ak@silmarill.org Mon Jun 4 22:35:34 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Mon, 04 Jun 2001 17:35:34 -0400 Subject: [Tutor] De-CSV-ing? In-Reply-To: <"from curtis.larsen"@Covance.Com> References: Message-ID: <20010604173534.A19943@sill.silmarill.org> On Mon, Jun 04, 2001 at 04:10:36PM -0500, Curtis Larsen wrote: > What would be the easiest (or simplest) way to convert a line from a CSV > file into a list or tuple? Sure, you can use ".split(',')" to break the > line into a list -- that's the easy part. For example, if each read > line in a CSV file were represented by string "s": > > s = "1,2,3,5.5,3.95,dog,cat,ferret" > s1 = s.split(",") > s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret'] > > That's great as far as it goes -- you have each value as a > uniquely-addressable item again. But is there an easy way to convert > the numbers-as-strings field values back to being numbers? Also, how Yeah, int() and float(). If value isn't convertable, they raise exceptions. > would you handle a CSV file where the strings were actually delimited by > (double or single) quotes? (e.g. the record would look like: > 1,2,3,"dog","cat","ferret",7.95 ) Do you have to loop through each > value in each line, or is there an easier/faster conversion approach? Well, I guess one way is to see if the first and last characters are quotes and then strip them. for item in list: if item[0] == '"' and item[-1] == '"': item = item[1:-1] > > Thanks! > Curtis > > > > ----------------------------------------------------- > Confidentiality Notice: This e-mail transmission > may contain confidential or legally privileged > information that is intended only for the individual > or entity named in the e-mail address. If you are not > the intended recipient, you are hereby notified that > any disclosure, copying, distribution, or reliance > upon the contents of this e-mail is strictly prohibited. > > If you have received this e-mail transmission in error, > please reply to the sender, so that we can arrange > for proper delivery, and then please delete the message > from your inbox. Thank you. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- The point of philosophy is to start with something so simple as not to seem worth stating, and to end with something so paradoxical that no one will believe it. From sarnold@earthling.net Tue Jun 5 03:54:47 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Mon, 4 Jun 2001 19:54:47 -0700 Subject: [Tutor] small (I hope) questions In-Reply-To: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu> Message-ID: <20010605025448.C4D9C1F62A@shiva.arnolds.bogus> On 4 Jun 01, at 14:25, Isaac Hall wrote: [snip] > a) I am trying to produce a pie chart of just random numbers in > a list to get started with this, however Im confused as to how to > call up a canvas, and draw the chart. [snip] Are you sure you want to code this yourself, as opposed to calling a graphics lib or using an external app? I think the WXPython package comes with a basic plotting lib. I know gnuplot works well with Python, and a windows version even comes with the ActiveState Python (gnuplot is standard on pretty much every Linux distribution). I've only used gnuplot on Linux, and it works fine; I fired up the above windows version and it worked with the demos. The gnuplot syntax is pretty straightforward; there's an example on one of my cheesy screenshots below (the last one on the page): http://arnolds.dhs.org/screenshots.html If you have your data in an ASCII file (in column vectors) then from within gnuplot you could plot the second and third columns: plot "this_file" using 2:3 with linespoints I never tried a pie chart, but it shouldn't be too hard. I also saw some cool visualization stuff at the last Python conference using VTK, but it's a commercial package (there may be something available for download). Steve From sarnold@earthling.net Tue Jun 5 04:18:11 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Mon, 4 Jun 2001 20:18:11 -0700 Subject: [Tutor] command prompt HOWTO (long) Message-ID: <20010605031811.707C11F62A@shiva.arnolds.bogus> Howdy: Judging from the lone response I got, I guess I've been expunged from the list, consigned to the bit-bucket, redirected to /dev/null 8-o Here it is, but it needs some work (some of the longer lines may get wrapped in transit). I'm open to suggestions... Python Command Prompt mini-HOWTO Steve Arnold 06-03-2001 sarnold@earthling.net Introduction This is an introduction to running Python programs from the command prompt in both DOS/Windows and X-Windows environments. You should be familiar with using a basic text editor, creating and saving files, knowing where they go when you save them, etc. Detailed info on these topics can be found elsewhere on the web (and is beyond the scope of this document). However, we will discuss some editing tips, setting up your environment, and various ways to run Python programs and capture the output. The DOS Command Prompt Most of my win32 experience is with Windows 9x and a little bit of NT4. The main difference is that NT has a more useful NT command prompt, as well as the DOS box, where you can actually set the size of the scroll buffer (among other things), but they are very similar as well. NT allows setting user-specific environment stuff, but 9x requires a login profile on a server for this. We'll assume the Windows box is not connected to a network in this case (except for a dial-up Internet connection). Setting up Your Environment All programs run inside an environment of some kind, and in this case there are both global settings and some that are specific to the DOS-shortcut you start from. The easiest place to put your global environment settings is in your autoexec.bat file. A DOS batch file is just a text file (with a .bat extension) that contains a sequence of DOS commands to run, and autoexec.bat is a special batch file that runs when DOS starts up (and before Windows starts). You should find autoexec.bat in the root of your C:\ drive (this file was more widely used back in the Windows 3x days, so you may not even have one). If you don't have one, just create one with a text editor. Tip: The basic Windows text editor is called Notepad.exe and is really not good for much at all (it can't even load or work with files bigger than 64k). Although you can use something like Word or Wordpad to edit text files, I wouldn't recommend it. If you don't already have some kind of programmer's editor, then here's the best free one (and it's way better than Notepad): http://www.winsite.com/info/pc/win95/misc/pfe101i.zip It's called Programmer's File Editor, and although it's no longer under development, the file above can be found on numerous ftp archives. The website for PFE used to be here: http://www.lancs.ac.uk/people/cpaap/pfe/ If you already have an autoexec.bat file, then just add some of the settings below. Here is an example file, with each line explained below (most non-Python stuff has already been removed): ************************ begin C:\autoexec.bat *********************** @C:\UTILS\NAV\NAVDX.EXE /Startup SET PATH=%PATH%;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20 SET ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components SET ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components SET HOME=C:\HOME\STEVE c:\windows\command\doskey.com dird=dir /ad $* ************************ end C:\autoexec.bat *********************** Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup This line is for Norton Antivirus for Win95. If you don't have it, don't worry (but you should probably have some form of virus protection). Line 2: SET PATH=%PATH%;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20 This line sets the path, which is where Windows looks for programs to run when you type the program name at a command prompt. The %PATH% is a variable that means "whatever the path was already set to". The default path for Windows 9x is usually "C:\windows;C:\windows\command" (notice that semicolons are used to separate entries in the path) so my complete path would be: PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20 To see what your path is, open a DOS prompt and type "set", which will show all your DOS environment variables. The first two entries above are where Windows and DOS programs reside, the DOS_STUF directory is where I put some additional DOS programs, next is where the GNU Ada compiler programs reside, and finally the DOS Python tools. You need this if you want to call the Python interpreter from anywhere on your hard drive. Lines 3 & 4: SET ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components SET ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components Extra junk telling the Ada compiler where to find things (this should be phased out soon and stored in the registry instead). Line 5: SET HOME=C:\HOME\STEVE This is a handy way to set a home directory (where you can keep your personal Python files, etc). It also helps with some programs that look for this variable. Line 6: c:\windows\command\doskey.com dird=dir /ad $* If you want to have a command history in your DOS box, i.e., where you can use the Up-arrow key to recall previous commands, then you need to load this program (it comes with Windows). So, unless you have other settings already in your autoexec.bat file, the basic settings for running Python programs would be: SET PATH=%PATH%;C:\PYTHON20 SET HOME=C:\HOME\STEVE c:\windows\command\doskey.com dird=dir /ad $* And don't forget to download the PFE editor above. If you installed Python to a different directory than the default shown above, then change it accordingly. The default DOS prompt shortcut is on your Start Menu under Start -> Programs -> MS-DOS Prompt. This is a special type of Windows shortcut that points to command.com, and allows you to set several other custom parameters for a given DOS session. I'd recommend making your own shortcut for Python; you might want to put it with the other Python menus (right-click on the Start menu and click Explore). Once you've started your Python-DOS box, select the Properties button on the toolbar at the top of the window. You should see several tabs of configuration options, some of which can make things more convenient. You may have noticed that your DOS box opened in the C:\Windows directory (if it takes over your whole screen, then press Alt-Tab to make a window). You can change this to point to wherever you keep your working Python files. For example, I would make a directory under my home directory above, such as: C:\HOME\STEVE\SRC\PYTHON Then on the Program tab in the MS-DOS Prompt Properties, I would enter the above path for the "Working" directory. That way, this particular DOS shortcut will always open in my Python source directory. Feel free to use the Change Icon button to give your DOS box a more appealing Python-esque icon (there are several .ico files in the main Python directory). You don't really need to change anything else, however, you may want to increase the Initial Environment size on the Memory tab to at least 1024. You can also play with the options on the Font tab to change the size of the window/fonts. However, you can't increase the size of your scroll buffer, so if the text output of your program scrolls off the top of your screen, about the only options you have are to pipe the output to the More command, or redirect it to a file (which we'll cover in just a minute). Running Python Programs Start your customized DPS prompt and type "set" to check your environment. You should see something like the following: TMP=C:\WINDOWS\TEMP TEMP=C:\WINDOWS\TEMP PROMPT=$p$g winbootdir=C:\WINDOWS COMSPEC=C:\COMMAND.COM ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components HOME=C:\HOME\STEVE PGPPATH=C:\INTERNET\PGP TZ=PST8PDT DIRCMD=/O BLASTER=A220 I5 D0 P300 windir=C:\WINDOWS PATH=C:\USR\GNAT\BIN;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\DOS_STUF;C:\PYTHON20 Including the C:\PYTHON20 directory in your path allows Windows to find both the DOS and win Python interpreters. For text-mode programs, you would call the PYTHON.EXE interpreter like this: C:\home\steve\src>python which.py pythonw.exe \PYTHON20\pythonw.exe The which.py program implements a version of the 'which' command that looks for a program in your PATH (in this case PYTHONW.EXE). If your program has more output than will fit on one screen, then you can pipe it (the pipe symbol is above your backslash key) to the More command, which will let you page down through the output one screen at a time: python which.py pythonw.exe|more The other option is to redirect the output to a file (which will end up in the current directory unless you specify a path): python which.py pythonw.exe > output.txt Starting PYTHON.EXE with no arguments will launch the Python interpreter. If you double click on PYTHONW.EXE, you will see that nothing (apparently) happens. PYTHON.EXE is the console version of Python, and is useful when you want to see what Python writes to the standard output. PYTHONW.EXE is the non-console version of Python, and does not show a console window. You would normally use it to run Python programs which create their own windows, programs running as server processes, etc. If you want to run a GUI program, then you would use PYTHONW.EXE (you would probably want to write a short DOS batch file to start your program). Most Python GUI programs you'll find floating around require the TCL/Tk package (Tkinter under Windows) for creating the windows, buttons, etc, however, more people are starting to use the GTK-based WXPython package. Both TCL/Tk and WXPython programs should run under both Linux/X-Windows and MS-Windows, provided you have all required packages installed. More info on this as available on the Python and ActiveState web sites: http://www.python.org/ http://www.ActiveState.com/index.html The Linux Command Prompt One of the major differences between DOS/NT and Linux command prompts (or shells) is that Linux/UNIX shells provide full-featured scripting languages to use within the shell environment. There are also several different shells to choose from such as the Bash shell, C shell, and Korn shell. Most Linux distributions seem to default to Bash, but you can always choose another. The syntax varies from one shell to the next (although they seem to fall into two main camps) so we will use the Bash shell syntax in the following examples. Setting up Your Environment Your Linux or UNIX environment should already be setup for you (for the most part). You can see your environment variables as before, by typing the 'set' command. You should see something like this: [sarnold@ptolemy sarnold]$ set BASH=/bin/bash BASH_ENV=/home/sarnold/.bashrc BASH_VERSINFO=([0]="2" [1]="04" [2]="11" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu") BASH_VERSION='2.04.11(1)-release' COLORS=/etc/DIR_COLORS COLUMNS=103 DIRSTACK=() DISPLAY=:2.0 EUID=501 GROUPS=() HISTFILE=/home/sarnold/.bash_history HISTFILESIZE=1000 HISTSIZE=1000 HOME=/home/sarnold HOSTNAME=ptolemy HOSTTYPE=i386 IFS=' ' INPUTRC=/etc/inputrc KDEDIR=/usr LANG=en_US LESSOPEN='|/usr/bin/lesspipe.sh %s' LINES=62 LOGNAME=sarnold LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37... MACHTYPE=i386-redhat-linux-gnu MAIL=/var/spool/mail/sarnold MAILCHECK=60 OPTERR=1 OPTIND=1 OSTYPE=linux-gnu PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/sarnold/bin PIPESTATUS=([0]="0") PPID=13536 PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' PS1='[\u@\h \W]\$ ' PS2='> ' PS4='+ ' PWD=/home/sarnold QTDIR=/usr/lib/qt-2.2.0 REMOTE_HOSTNAME=rama.arnolds.bogus REMOTE_IPADDRESS=192.168.0.7 SHELL=/bin/bash SHELLOPTS=braceexpand:hashall:histexpand:monitor:history:interactive-comments:emacs SHLVL=4 SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass TERM=xterm TZ=PST8PDT UID=501 USER=sarnold USERNAME=sarnold VNCDESKTOP=X WINDOWID=8388622 _=PATH i=/etc/profile.d/which-2.sh langfile=/home/sarnold/.i18n sourced=1 mc=() { mkdir -p ~/.mc/tmp 2>/dev/null; chmod 700 ~/.mc/tmp; MC=~/.mc/tmp/mc-$$; /usr/bin/mc -P "$@" >"$MC"; cd "`cat $MC`"; /bin/rm "$MC"; unset MC } As you can see, there's much more information here than in the previous example. Don't worry if you don't know what it all means (I certainly don't) but you can check your path to make sure it has the right directories in it. One slight difference though: DOS will look in the current directory for programs first, then the path, whereas Linux will not look in the current directory unless you explicitly add it to your path using the '.' notation (which is not a very good idea). If you want a place to put your working Python scripts (as well as shell scripts) then you should make a bin directory under your home directory (as above) and then add it to your path. To modify your personal path setting, as well as other shell settings, then you should edit your .bash_profile in your home directory (it starts with a '.' so it's hidden, like the DOS Hidden file attribute). Here is my modified .bash_profile: [sarnold@ptolemy sarnold]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin BASH_ENV=$HOME/.bashrc USERNAME="sarnold" export USERNAME BASH_ENV PATH Notice that in Bash syntax, you must first SET the variables, then EXPORT them. Your Linux distribution should have come with Python already installed, so you would probably find the Python interpreter in /usr/bin. Use the 'which' command to locate it (you could also try the 'locate' command, but you might have to create the locatedb first if your machine doesn't run all night) like so: [sarnold@ptolemy sarnold]$ which python /usr/bin/python You can run your python programs exactly the same way as under Windows, except there's no distinction between running a text-mode program or a GUI program. Of course, you need to be running X to run most GUI programs, but that's beyond the scope of this HOWTO. From cynic@mail.cz Tue Jun 5 05:15:03 2001 From: cynic@mail.cz (Cynic) Date: Tue, 05 Jun 2001 06:15:03 +0200 Subject: [Tutor] command prompt HOWTO (long) In-Reply-To: <20010605031811.707C11F62A@shiva.arnolds.bogus> Message-ID: <5.1.0.14.2.20010605053249.026df008@mail.cz> At 20:18 4.6. 2001 -0700, Stephen L Arnold wrote: >Howdy: > >Judging from the lone response I got, I guess I've been expunged >from the list, consigned to the bit-bucket, redirected to /dev/null >8-o > >Here it is, but it needs some work (some of the longer lines may >get wrapped in transit). I'm open to suggestions... > >Python Command Prompt mini-HOWTO I think you should be more to the point -- strip anything not related to python, namely stuff like this: >Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup > >This line is for Norton Antivirus for Win95. If you don't have it, >don't worry (but you should probably have some form of virus >protection). If I were looking for a quick guide to setting up my machine for Python, and found a 14kB of stuff largely OT, I wouldn't be very happy. Well, hmm, I'd call this anything but _mini_-HOWTO. I think it's actually pretty much of a _maxi_-HOWTO considering you're tutoring people not how to _program_ (be it in Python or any other lingo), but basic usage of their oh-so-friendly windows (linux) computers. As it is, it should be called windows-and-linux-for-dummies-HOWTO I don't want to sound sarcastic or something, but you could have save yourself some time if you made it a true mini-HOWTO saying "Read your Windows User's Manual" or "type 'man bash' (without quotes)". :) Or, if you prefer this longer version (windoze only): """If you had associated .py files with python.exe, and, upon double- clicking foo.py file, a dos window (well, it's not a dos window, it's a 32-bit console window) flashes on your screen, and disappears, your options are: win9x: create a batch invoking the foo.py program, and uncheck the "close when finished" checkbox on the "program" card in its properties. both win9x and NT: create a batch invoking another cmd instance with /k switch, that will invoke your foo.py both win9x and NT: start an instance of shell, and invoke foo.py from there. """ using batches is the approach Perl has taken with it's standard programs, and has the advantage that you can type just the name of the program (sans extension), and have it executed. I seem to recall reading somewhere in Perl's doc-set that it also has a disadvantage -- something about command.com/cmd.exe being dumb enough about passing arguments, but dunno what exactly it was. I've only skimmed the Linux part, but it looked similar to the windows half. Oh, BTW, I found a terrific set of win32 ports of common unix commands, which, among others, contains which. :)) http://unxutils.sourceforge.net/ an idea, maybe stupid: what about a wrapper which would take care of the cmd x command /k invokation? something you could import into your script, something that would require one or two lines of code per use? would this be possible with python? cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7 From ak@silmarill.org Tue Jun 5 06:09:04 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Tue, 05 Jun 2001 01:09:04 -0400 Subject: [Tutor] command prompt HOWTO (long) In-Reply-To: <"from cynic"@mail.cz> References: <20010605031811.707C11F62A@shiva.arnolds.bogus> <5.1.0.14.2.20010605053249.026df008@mail.cz> Message-ID: <20010605010904.A20631@sill.silmarill.org> On Tue, Jun 05, 2001 at 06:15:03AM +0200, Cynic wrote: > At 20:18 4.6. 2001 -0700, Stephen L Arnold wrote: > >Howdy: > > > >Judging from the lone response I got, I guess I've been expunged > >from the list, consigned to the bit-bucket, redirected to /dev/null > >8-o > > > >Here it is, but it needs some work (some of the longer lines may > >get wrapped in transit). I'm open to suggestions... > > > >Python Command Prompt mini-HOWTO > > I think you should be more to the point -- strip anything not related > to python, namely stuff like this: > > >Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup > > > >This line is for Norton Antivirus for Win95. If you don't have it, > >don't worry (but you should probably have some form of virus > >protection). > > If I were looking for a quick guide to setting up my machine for Python, > and found a 14kB of stuff largely OT, I wouldn't be very happy. I'd like to second that - when I was learning linux ~3 years ago, this was the major stumbling block for me - most of written help is overwhelming. I think the problem is that when a large company like adobe or ms write help, they take real-life dumb newbies and try various approaches to see what works best. When it comes to linux online docs, those who write them don't really understand what newbies need, so they either write terse man pages, or get tired of getting frequently asked questions and just write everything (we don't know what happened before big bang, but [...]). It's sad how every newbie is disgusted by lack of good optimized for the common case docs, and naively promises to himself to correct that as soon as he gets the hang of things (i know i did), and then when he does, he no longer remembers what would be helpful to him when he was a newbie. -- True sailing is dead - Jim From sarnold@earthling.net Tue Jun 5 06:27:27 2001 From: sarnold@earthling.net (Stephen L Arnold) Date: Mon, 4 Jun 2001 22:27:27 -0700 Subject: [Tutor] command prompt HOWTO (shorter) In-Reply-To: <20010605010904.A20631@sill.silmarill.org> References: <"from cynic"@mail.cz> Message-ID: <20010605052727.E05EC1F62A@shiva.arnolds.bogus> On 5 Jun 01, at 1:09, sill@optonline.net wrote: > On Tue, Jun 05, 2001 at 06:15:03AM +0200, Cynic wrote: [snip] > > If I were looking for a quick guide to setting up my machine for Python, > > and found a 14kB of stuff largely OT, I wouldn't be very happy. > > I'd like to second that [snip] Okay, it lost 5k of non-Python specific stuff, but I'm having trouble figuring out what to cut next. Anybody want to see the new version, or would it be too much clogging up your mailbox? Steve From r.b.rigilink@chello.nl Tue Jun 5 07:09:33 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Tue, 05 Jun 2001 08:09:33 +0200 Subject: [Tutor] De-CSV-ing? References: Message-ID: <3B1C779D.78BB6D2B@chello.nl> Curtis Larsen wrote: > > What would be the easiest (or simplest) way to convert a line from a CSV > file into a list or tuple? Sure, you can use ".split(',')" to break the > line into a list -- that's the easy part. For example, if each read > line in a CSV file were represented by string "s": > > s = "1,2,3,5.5,3.95,dog,cat,ferret" > s1 = s.split(",") > s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret'] > > That's great as far as it goes -- you have each value as a > uniquely-addressable item again. But is there an easy way to convert > the numbers-as-strings field values back to being numbers? Also, how > would you handle a CSV file where the strings were actually delimited by > (double or single) quotes? (e.g. the record would look like: > 1,2,3,"dog","cat","ferret",7.95 ) Do you have to loop through each > value in each line, or is there an easier/faster conversion approach? > Hi Curtis, How about this: def float_it(item): '''try to change item to float, if that's not possible return item itself''' try: return float(item) except ValueError: return item line = "1,2,3,5.5,3.95,dog,cat,ferret" items = line.split(',') items = map(float_it, items) # call float_it for each item print items gives [1.0, 2.0, 3.0, 5.5, 3.9500000000000002, 'dog', 'cat', 'ferret'] Hope this helps, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From SBrunning@trisystems.co.uk Tue Jun 5 09:21:14 2001 From: SBrunning@trisystems.co.uk (Simon Brunning) Date: Tue, 5 Jun 2001 09:21:14 +0100 Subject: [Tutor] De-CSV-ing? Message-ID: <31575A892FF6D1118F5800600846864D78BCCD@intrepid> > From: Curtis Larsen [SMTP:curtis.larsen@Covance.Com] > What would be the easiest (or simplest) way to convert a line from a CSV > file into a list or tuple? Well, the usual way of decoding csv files is to use a finite state machine - see . Don't worry, that aren't as complicated as this page makes them sound! But before writing anything yourself, it's often worth seeing if anyone else has written something useful. After all, csv file processing is pretty common, so someone else is *bound* to have done this before. The first place to look is the Vaults of Parnassus - . Searching there for 'csv' takes me to a link to the 'ASV' module. Hmmm. The ASV page seems to be down. But the module can still be downloaded - . See here - for google's cache of the ASV page. Hope this helps... Cheers, Simon Brunning TriSystems Ltd. sbrunning@trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From karimy@nipltd.com Tue Jun 5 09:35:58 2001 From: karimy@nipltd.com (Karim Yaici) Date: Tue, 5 Jun 2001 09:35:58 +0100 Subject: [Tutor] small (I hope) questions References: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu> Message-ID: <009c01c0ed9a$8b74ad80$a5020a0a@private.nipltd.com> > a) I am trying to produce a pie chart of just random numbers in a > list to get started with this, however Im confused as to how to call up > a canvas, and draw the chart. Just to answer to this question. I have used sometime ago a library called GDChart which allows the creation of charts (lines, pie...) as PNG, GIF...which you can then used with GUI. I though you might find it useful. Here is the link http://athani.pair.com/msteed/software/gdchart/ Cheers Karim From unsubscribe@virtualgamblinghouse.com Tue Jun 5 10:19:40 2001 From: unsubscribe@virtualgamblinghouse.com (Orbital casino) Date: Tue, 5 Jun 2001 11:19:40 +0200 Subject: [Tutor] Orbital casino Message-ID: <200106050919.LAA03240@smtp.fol.nl> This is a multi-part message in MIME format. --orbitalcasino991732780 Content-Type: multipart/alternative; boundary="orbitalcasino991732780xx" --orbitalcasino991732780xx Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable -------------------------------------- $ 10 FREE - NO PURCHASE NECESSARY!!! -------------------------------------- Orbital Online Casino offers new Players -- $10 FREE - NO PURCHASE NECESSARY!-- All you have to do is download the FREE software and open a Real Account. On top of this great DEAL, they are offering you a 100% First Purchase Bonus!!!!! That`s right, whatever your first Deposit into your Real account is, Orbital Online Casino will match your purchase up to $100!! See for yourself why Orbital Online Casino is the SAFEST BET on the NET ::CLICK HERE:: http://www.virtualgamblinghouse.com -------------------------------------- To claim your FREE cash!! -------------------------------------- If you no longer wish to receive further e-mails from Virtualgamblinghouse, please reply to: --unsubscribe@virtualgamblinghouse.com-- with the single word "unsubscribe" as the subject of the message. Your name will then be removed from our mailing list. --orbitalcasino991732780xx Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: Base64 PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9u YWwvL0VOIj4KCjxodG1sPgo8aGVhZD4KCTx0aXRsZT5vIHIgYiBpIHQgYSBsICZuYnNwO28g biBsIGkgbiBlICZuYnNwO2MgYSBzIGkgbiBv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zMiIGJvcmRlcj0iMCI+PC9hPjwvcHJlPgogICAgCgk8L3RkPgo8L3Ry Pgo8L3RhYmxlPgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNp bmc9IjAiIHdpZHRoPSI2MDciPgo8dHI+Cgk8dGQgd2lkdGg9IjE1Ij4mbmJzcDs8L3RkPgoJ PHRkIHdpZHRoPSI1OTIiPgoJPGZvbnQgc2l6ZT0iMSIgZmFjZT0iQXJpYWwsIEhlbHZldGlj YSwgc2Fucy1zZXJpZiIgY29sb3I9ImJsYWNrIj4KCUlmIHlvdSBubyBsb25nZXIgd2lzaCB0 byByZWNlaXZlIGZ1cnRoZXIgZS1tYWlscyBmcm9tIFZpcnR1YWxnYW1ibGluZ2hvdXNlLCBw bGVhc2UgcmVwbHkgdG8gPGEgaHJlZj0ibWFpbHRvOnVuc3Vic2NyaWJlQHZpcnR1YWxnYW1i bGluZ2hvdXNlLmNvbSI+dW5zdWJzY3JpYmVAdmlydHVhbGdhbWJsaW5naG91c2UuY29tPC9h Pgp3aXRoIHRoZSBzaW5nbGUgd29yZCAidW5zdWJzY3JpYmUiIGFzIHRoZSBzdWJqZWN0IDxi cj5vZiB0aGUgbWVzc2FnZS4gWW91ciBuYW1lIHdpbGwgdGhlbiBiZSByZW1vdmVkIGZyb20g b3VyIG1haWxpbmcgbGlzdC48YnI+PC9mb250Pgo8L3RkPgo8L3RyPgo8L3RhYmxlPgo8aW1n IHNyYz0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxpbmdob3VzZS5jb20vc3AuZ2lmIj4KCjwv Ym9keT4KPC9odG1sPgoK --orbitalcasino991732780xx-- --orbitalcasino991732780 Content-Type: image/gif; name="bg_01.jpg " Content-Transfer-Encoding: base64 Content-Location: bg_01.jpg /9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA Af/bAIQAEQwMDA0MEQ0NERkQDhAZ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OxHRPu t1Zq7F3gtVNUJrjGVFX6GsUeP3fKua7aei/s7snjpnYjLcW5JcU7cXJf3oxMXTNy6er3yaTX t3Zo73usEtVMuwq5ze7VaYpJcAZbDfPLZbr4a97MW+Xcx9y3Xw97zA8J2a/f/wCoC7zPdXHg 1HsRmneu3HWcmzS+Wcx9x3Xw97zCnyzmfDY7r4e75heP0Zvsz12/7Y3Jo07bf3LK0yrKHQR8 q5p7huvh7vmAvlPNfcN18Pd8wrrn4E9mLmbT7tUeaQnOri1RYGTc7q5uMJvyVlHoLXKea1x2 G6+Hu+YX/tXNfcN18Pd8wJpj4avutmLtGKSowo4o1y5VzRr/AOBuvh7vmFR5VzVZ7DdfD3fM HFYzrnrPuyPAtS6cTXLlXNHlsN18Pd8wr/aebe4br4e75hYq8p3n3ZWo0TjnxQNDauVc19w3 Xw93zC3yrmmf8Buq/wD17vmDijy17xixL7TX/tPNPcN18Pd8wv8A2rmnuG6+Hu+YWF5TvPuy aegmk2LlfNPcN18Pd8wJcs5nx2O6+Hu+YWKfLXvPuyJF6KdhrXLeZe47r4e75gS5dzHjsd18 Pe8wcLy17z7s0Ymuzb6yLl/MV/od18Pe8wZDacyi8Nluvh73mGozbO8a7VvBEDsw3cUtez3S /wDGv+zIaYzM9XvyEIZc0IQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCE n//Z --orbitalcasino991732780 Content-Type: image/gif; name="bg_02.jpg " Content-Transfer-Encoding: base64 Content-Location: bg_02.jpg /9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0 NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgBMgGX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LOvLUxkv/AM+qz+iajujJdmX1dNqn+q6juhyuojiW1tZM0lw7Ude3T3yezSap/qt/ dmWei1j+rotV7Nd3YSuqGm5kyws6y1STIfL+Yb1otV7Nd9gI6PmS36HVez3fYMrVXJnZh7mN LcBs9Ro01koTWJcKKlpeYeo6r2a77BP3XX+o6r2a77BEQzsWfHZQ71Xieho1Vah50vpEv5tp 4bIvil1I4fYcyxh6PV46vu932Bfuuu9S1Xs13dlO7gx2YJl3p/cjVfzS+zKi+CPkMcpuTzJ5 b6XtG+66/wBS1Xs132BJaXmWNmg1T/V7fsEPczZZMNVpeq8RXIqsvhFbX9BFmj5zLYuX6pL9 Ht+wUvlfN3v0Gq9nt+wNV6mV+8qlFWVWamct2xFDedpr/ZPNv/X6r2e37Afsnm3/AK/Vez2/ YKWhx2y2txZjwyUjX+yea7/2fqs/o9v2CY8p5q352g1SX6Pb9gGyUl5l7zHtexLLL6tPlpy3 myvlevh+Y6r2e77BdHQ67p0Wq9mu+wZWtZ8mdWKmJa2vSf8AkiiEMIsUS5aPXepar2a7ux1p dZ6nqvZru7Mmrv5X7jrrkwpRvp/cilRY2C37trfU9V7Nd3Zv5d4d5jr5RlqIS0Wjb8+U/N1E 47dkIb4Z65YfkJVLNxDHbuMVVO+r+hybuQwlX4Z5lqJ+bVqHfbXJtba41Rq4vkzW8eTaB6T7 ppvun3Ls1917Psey6Oy4eDh+jYB1bfh2+yDyPU/F9SPn3/XJcAAUZgAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAH//2Q== --orbitalcasino991732780 Content-Type: image/gif; name="clickhere.gif " Content-Transfer-Encoding: base64 Content-Location: clickhere.gif R0lGODlhuQAhAMQQAHFvmJiWtEtIfMzL2vLy9rKxx4uJq+Xl7FhVhtjY42Vij6Wkvn58or++ 0P///z47c////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ACH5BAEAABAALAAAAAC5ACEAAAX/ICSOZGmeaKqubOu+cCzPdG3feK7vfO//wKDIQSwaj8ik cslsOp/QqHQKhREf2Kx2y+16v+CweEwum89kYsuBbrvf8Lhc7lix5/i8fs/v1lF3fYKDhIVe fyaBhlsARABbAVdojQ6PaEQBi4uIJIqaWZSWWZGeZKFtmJ+GnEOqjI5bCACiZqeXDpmug6wQ pXkCAQMDCwhctqABubELwgECxrDAyWm4CgXDxVzAwsRdyQAGA8pZBg0DBbR7vL5zCAdGBNmg sFqkXAwERgnQlQ8DDgQUUEsA75kWAQSLBORC5J+DfVoKHDEgaJ2gBgAN4HNQ4FW/epK05EvA gBRFLaEk/zo4OaZIAAAqWWKRSEAjwQMMiRxIsECLAUwAMDqQp8ciHwGpHgRoMO7BMSz2tDAg IvBBgQIynRIRmjVMQyxIcW1JqoBeFp3PDGL5NyBLvqZ4jO55yi9d1FEhvVAqks6rWCxJsVAq kIxUUyIdc4pL9q4tH7l66Hq0m1dpZX4AHTimpiyw1iSH/45Nsrlooj5lV2JB8FLtZ8qeSGUD 8NIjOiJdvwT2nJqBX7gP8vVcdbpP45lEXNO9uzrpO4jz+kk84BrMbtFY3jWAqrm65yzTnzVK 0HcOZD0/HewkMjw6bC4qE7xz4BtltLecz2K3rD7h9tHApUaAQ9T1cZ4eAeTDXn5dkFwmwAIK dWVLJPG0JNp3SinIUXUPYCjYfJpV9Vhxg8zC4RsCzKKLMQCcSIYCABA1YgnsrGjjjZucUCOO PPZoHiA+Binkj0AOaeSRLdmB5JJMnrXGjk1GqYoaL1Bh5ZVYZqnlllcK4eWXYIYp5phklmnm mWimqeaabLb5ZQgAOw== --orbitalcasino991732780 Content-Type: image/gif; name="invisible.gif " Content-Transfer-Encoding: base64 Content-Location: invisible.gif R0lGODlhCgAKAIAAAP///wAAACH5BAEAAAAALAAAAAAKAAoAAAIIhI+py+0PYysAOw== --orbitalcasino991732780 Content-Type: image/gif; name="log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BdxM5jOkwchvDiIhEIBCQZShAyvyA5575Yc5TOwQRZhiIfKAgzNUsBBkCPIg DP20P6zhDWkWhAbs1wFNh2ILP7BAHArh44IRYgdTELXP2kg3CAmkaA3KznMUfsBnQ1AgDHAg hATOs4ZO/8ECcPA2Bfjs4y2QmRBwgMMR6Jzjdrv73fCOt7znTe962/ve+M63vvfN7367IhAA Ow== --orbitalcasino991732780-- From unsubscribe@virtualgamblinghouse.com Tue Jun 5 10:19:44 2001 From: unsubscribe@virtualgamblinghouse.com (Orbital casino) Date: Tue, 5 Jun 2001 11:19:44 +0200 Subject: [Tutor] Orbital casino Message-ID: <200106050919.LAA03253@smtp.fol.nl> This is a multi-part message in MIME format. --orbitalcasino991732784 Content-Type: multipart/alternative; boundary="orbitalcasino991732784xx" --orbitalcasino991732784xx Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable -------------------------------------- $ 10 FREE - NO PURCHASE NECESSARY!!! -------------------------------------- Orbital Online Casino offers new Players -- $10 FREE - NO PURCHASE NECESSARY!-- All you have to do is download the FREE software and open a Real Account. On top of this great DEAL, they are offering you a 100% First Purchase Bonus!!!!! That`s right, whatever your first Deposit into your Real account is, Orbital Online Casino will match your purchase up to $100!! See for yourself why Orbital Online Casino is the SAFEST BET on the NET ::CLICK HERE:: http://www.virtualgamblinghouse.com -------------------------------------- To claim your FREE cash!! -------------------------------------- If you no longer wish to receive further e-mails from Virtualgamblinghouse, please reply to: --unsubscribe@virtualgamblinghouse.com-- with the single word "unsubscribe" as the subject of the message. Your name will then be removed from our mailing list. --orbitalcasino991732784xx Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: Base64 PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9u YWwvL0VOIj4KCjxodG1sPgo8aGVhZD4KCTx0aXRsZT5vIHIgYiBpIHQgYSBsICZuYnNwO28g biBsIGkgbiBlICZuYnNwO2MgYSBzIGkg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D0iMzMiIGJvcmRlcj0iMCI+PC9hPjwvcHJlPgogICAgCgk8L3RkPgo8L3Ry Pgo8L3RhYmxlPgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNp bmc9IjAiIHdpZHRoPSI2MDciPgo8dHI+Cgk8dGQgd2lkdGg9IjE1Ij4mbmJzcDs8L3RkPgoJ PHRkIHdpZHRoPSI1OTIiPgoJPGZvbnQgc2l6ZT0iMSIgZmFjZT0iQXJpYWwsIEhlbHZldGlj YSwgc2Fucy1zZXJpZiIgY29sb3I9ImJsYWNrIj4KCUlmIHlvdSBubyBsb25nZXIgd2lzaCB0 byByZWNlaXZlIGZ1cnRoZXIgZS1tYWlscyBmcm9tIFZpcnR1YWxnYW1ibGluZ2hvdXNlLCBw bGVhc2UgcmVwbHkgdG8gPGEgaHJlZj0ibWFpbHRvOnVuc3Vic2NyaWJlQHZpcnR1YWxnYW1i bGluZ2hvdXNlLmNvbSI+dW5zdWJzY3JpYmVAdmlydHVhbGdhbWJsaW5naG91c2UuY29tPC9h Pgp3aXRoIHRoZSBzaW5nbGUgd29yZCAidW5zdWJzY3JpYmUiIGFzIHRoZSBzdWJqZWN0IDxi cj5vZiB0aGUgbWVzc2FnZS4gWW91ciBuYW1lIHdpbGwgdGhlbiBiZSByZW1vdmVkIGZyb20g b3VyIG1haWxpbmcgbGlzdC48YnI+PC9mb250Pgo8L3RkPgo8L3RyPgo8L3RhYmxlPgo8aW1n IHNyYz0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxpbmdob3VzZS5jb20vc3AuZ2lmIj4KCjwv Ym9keT4KPC9odG1sPgoK --orbitalcasino991732784xx-- --orbitalcasino991732784 Content-Type: image/gif; name="bg_01.jpg " Content-Transfer-Encoding: base64 Content-Location: bg_01.jpg /9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA Af/bAIQAEQwMDA0MEQ0NERkQ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8pjzOxHRPu t1Zq7F3gtVNUJrjGVFX6GsUeP3fKua7aei/s7snjpnYjLcW5JcU7cXJf3oxMXTNy6er3yaTX t3Zo73usEtVMuwq5ze7VaYpJcAZbDfPLZbr4a97MW+Xcx9y3Xw97zA8J2a/f/wCoC7zPdXHg 1HsRmneu3HWcmzS+Wcx9x3Xw97zCnyzmfDY7r4e75heP0Zvsz12/7Y3Jo07bf3LK0yrKHQR8 q5p7huvh7vmAvlPNfcN18Pd8wrrn4E9mLmbT7tUeaQnOri1RYGTc7q5uMJvyVlHoLXKea1x2 G6+Hu+YX/tXNfcN18Pd8wJpj4avutmLtGKSowo4o1y5VzRr/AOBuvh7vmFR5VzVZ7DdfD3fM HFYzrnrPuyPAtS6cTXLlXNHlsN18Pd8wr/aebe4br4e75hYq8p3n3ZWo0TjnxQNDauVc19w3 Xw93zC3yrmmf8Buq/wD17vmDijy17xixL7TX/tPNPcN18Pd8wv8A2rmnuG6+Hu+YWF5TvPuy aegmk2LlfNPcN18Pd8wJcs5nx2O6+Hu+YWKfLXvPuyJF6KdhrXLeZe47r4e75gS5dzHjsd18 Pe8wcLy17z7s0Ymuzb6yLl/MV/od18Pe8wZDacyi8Nluvh73mGozbO8a7VvBEDsw3cUtez3S /wDGv+zIaYzM9XvyEIZc0IQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCE n//Z --orbitalcasino991732784 Content-Type: image/gif; name="bg_02.jpg " Content-Transfer-Encoding: base64 Content-Location: bg_02.jpg /9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0 NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgB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vUVPLOvLUxkv/AM+qz+iajujJdmX1dNqn+q6juhyuojiW1tZM0lw7Ude3T3yezSap/qt/ dmWei1j+rotV7Nd3YSuqGm5kyws6y1STIfL+Yb1otV7Nd9gI6PmS36HVez3fYMrVXJnZh7mN LcBs9Ro01koTWJcKKlpeYeo6r2a77BP3XX+o6r2a77BEQzsWfHZQ71Xieho1Vah50vpEv5tp 4bIvil1I4fYcyxh6PV46vu932Bfuuu9S1Xs13dlO7gx2YJl3p/cjVfzS+zKi+CPkMcpuTzJ5 b6XtG+66/wBS1Xs132BJaXmWNmg1T/V7fsEPczZZMNVpeq8RXIqsvhFbX9BFmj5zLYuX6pL9 Ht+wUvlfN3v0Gq9nt+wNV6mV+8qlFWVWamct2xFDedpr/ZPNv/X6r2e37Afsnm3/AK/Vez2/ YKWhx2y2txZjwyUjX+yea7/2fqs/o9v2CY8p5q352g1SX6Pb9gGyUl5l7zHtexLLL6tPlpy3 myvlevh+Y6r2e77BdHQ67p0Wq9mu+wZWtZ8mdWKmJa2vSf8AkiiEMIsUS5aPXepar2a7ux1p dZ6nqvZru7Mmrv5X7jrrkwpRvp/cilRY2C37trfU9V7Nd3Zv5d4d5jr5RlqIS0Wjb8+U/N1E 47dkIb4Z65YfkJVLNxDHbuMVVO+r+hybuQwlX4Z5lqJ+bVqHfbXJtba41Rq4vkzW8eTaB6T7 ppvun3Ls1917Psey6Oy4eDh+jYB1bfh2+yDyPU/F9SPn3/XJcAAUZgAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAH//2Q== --orbitalcasino991732784 Content-Type: image/gif; name="clickhere.gif " Content-Transfer-Encoding: base64 Content-Location: clickhere.gif R0lGODlhuQAhAMQQAHFvmJiWtEtIfMzL2vLy9rKxx4uJq+Xl7FhVhtjY42Vij6Wkvn58or++ 0P///z47c////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ACH5BAEAABAALAAAAAC5ACEAAAX/ICSOZGmeaKqubOu+cCzPdG3feK7vfO//wKDIQSwaj8ik cslsOp/QqHQKhREf2Kx2y+16v+CweEwum89kYsuBbrvf8Lhc7lix5/i8fs/v1lF3fYKDhIVe fyaBhlsARABbAVdojQ6PaEQBi4uIJIqaWZSWWZGeZKFtmJ+GnEOqjI5bCACiZqeXDpmug6wQ pXkCAQMDCwhctqABubELwgECxrDAyWm4CgXDxVzAwsRdyQAGA8pZBg0DBbR7vL5zCAdGBNmg sFqkXAwERgnQlQ8DDgQUUEsA75kWAQSLBORC5J+DfVoKHDEgaJ2gBgAN4HNQ4FW/epK05EvA gBRFLaEk/zo4OaZIAAAqWWKRSEAjwQMMiRxIsECLAUwAMDqQp8ciHwGpHgRoMO7BMSz2tDAg IvBBgQIynRIRmjVMQyxIcW1JqoBeFp3PDGL5NyBLvqZ4jO55yi9d1FEhvVAqks6rWCxJsVAq kIxUUyIdc4pL9q4tH7l66Hq0m1dpZX4AHTimpiyw1iSH/45Nsrlooj5lV2JB8FLtZ8qeSGUD 8NIjOiJdvwT2nJqBX7gP8vVcdbpP45lEXNO9uzrpO4jz+kk84BrMbtFY3jWAqrm65yzTnzVK 0HcOZD0/HewkMjw6bC4qE7xz4BtltLecz2K3rD7h9tHApUaAQ9T1cZ4eAeTDXn5dkFwmwAIK dWVLJPG0JNp3SinIUXUPYCjYfJpV9Vhxg8zC4RsCzKKLMQCcSIYCABA1YgnsrGjjjZucUCOO PPZoHiA+Binkj0AOaeSRLdmB5JJMnrXGjk1GqYoaL1Bh5ZVYZqnlllcK4eWXYIYp5phklmnm mWimqeaabLb5ZQgAOw== --orbitalcasino991732784 Content-Type: image/gif; name="invisible.gif " Content-Transfer-Encoding: base64 Content-Location: invisible.gif R0lGODlhCgAKAIAAAP///wAAACH5BAEAAAAALAAAAAAKAAoAAAIIhI+py+0PYysAOw== --orbitalcasino991732784 Content-Type: image/gif; name="logo.gif " Content-Transfer-Encoding: base64 Content-Location: logo.gif R0lGODlhhQBIAOZ/APXHV7CxtJhuB9GqT+eqFu7Kd3WIr3Fwa7rE2al6CbWDCfPTiNWZC29R B4aVseSlDseucCI1WvX08v735ujr83F6itXb5ixBbLW8yee0O9zh7OetIykrLJqt08/Iuq2S TcyTC/bis//+/ExRWui4RfW5KkdTaHFlSeixK62ccBs1aoJ2U8TGyY5xKsWYKqm41vz58+7w 9a+li/PaoMTK1cSNCZmcn0Q3FfH0+V1rhbykZ8vU5+e8VPC9ROvr6tLW3P79+ZekvaaGOMq7 muTj4fX4/Nzc3M3S2++5OpiPdaayyIKEhdHS0lxiadyfDtirPkZBM/j4+PvEPvf394aKlnOQ ydjUx/KyF8uUFODl8GJRJeXo7+/r4lNtpOSvMoReBdSbINXY3zBLgEddiaGsw/v9/8OeSK++ 2/Hw7/f6/5SRhr/L4ZWAStDBnF1ECvz7+t3f4+bm5mRcR4ucv3hlNWp9pIU6a8/P0NjX1dbf 8L6JCeKhBjQ6Rdy6Zf///////yH5BAEAAH8ALAAAAACFAEgAAAf/gH+Cg4SFhoeIiYqLjI2O j5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGys7SjMhA8BTMACwsFAH0QtcOI YwdCLhslUlIAADMhITPQMwsAFcTZfystXw1u4F8KKD0FIVzR1QBSA9q1TU0mF2KEdnYNDz3n IUgbKBsPsLgzlaPCEjVJkhzIUUjMBUURhEQLUaAAgT1OQCiwM1DULWfMSojM8ETHkkcBds3Y 4OwBCD0JOHb0lOJXDyQlAO5h8LKGTwUHGqkBgGLlAwAksCgQIHPmJpsZUBBgUEOPgAY3OGjl 4EYLw0UppKBY0GMPAR4DFGhxuikF0gwb/6bC/OKGw0ND9Bb1QYKiAI+dWMwIMcE2E4S3cUEk EPCFQ4RKSYiy5JExQYIVhTFBkELin0vLDThc4pHBC8seDGA2uJuZklseXggQcKKazyUdAEwT yDAApgDbrSv16lWxwBCTlzwQ98Xjy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OHCSBdxM5jOkwchvDiIhEIBCQZShAyvyA5575Yc5TOwQRZhiIfKAgzNUsBBkCPIg DP20P6zhDWkWhAbs1wFNh2ILP7BAHArh44IRYgdTELXP2kg3CAmkaA3KznMUfsBnQ1AgDHAg hATOs4ZO/8ECcPA2Bfjs4y2QmRBwgMMR6Jzjdrv73fCOt7znTe962/ve+M63vvfN7367IhAA Ow== --orbitalcasino991732784-- From arcege@speakeasy.net Tue Jun 5 12:50:53 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Tue, 5 Jun 2001 07:50:53 -0400 (EDT) Subject: [Tutor] small (I hope) questions In-Reply-To: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu> from "Isaac Hall" at Jun 04, 2001 02:25:38 PM Message-ID: <200106051150.f55BorL03332@dsl092-074-184.bos1.dsl.speakeasy.net> Isaac Hall wrote > first, let me introduce myself a little as I am new to this list (but Welcome. > I may well be widely known as the guy with all the dumb questions > soon...I hope not) Ive just begun working with Python and Tkinter in > physics applications, and Im getting stuck in some fairly minor aspects > of this. I have previously only programmed in C/C++. anyway my > question(s) are: > a) I am trying to produce a pie chart of just random numbers in a > list to get started with this, however Im confused as to how to call up > a canvas, and draw the chart. All you need is a little math to get the values properly set up (but then this will be the same with just about any package. Here is a segment to help you start: size = (200, 200) graph = Canvas(graphicframe, height=size[0], width=size[1]) # get the total representing the circumference sum = reduce(operator.add, values) # starting angle lastangle = 0.0 for i in range(len(values)): item = values[i] # how much of the pie do we eat up percentage = (item / sum) # calculate ending angle based on that percentage newangle = lastangle + (percentage * 360.0) # create a new pie arc in the circle # the "get_indexed_color()" function is something you'll need to # write, you should get a unique color for each value, probably # not repeat the colors, and likely start with the primary colors # (red, yellow, blue) first graph.create_arc(0, 0, size[0], size[1], start=lastangle, extent=newangle, fill=get_indexed_color(i), style='pieslice' ) lastangle=newangle You probably have to tweek things to get the details to work (I'm not feeling well, so not going to fully debug this, sorry), but all you need is a little geometry. > b) in addition to the pie chart, I also need to put these numbers in > a table (which I have figured out, however I would like to be able to > create this so that the pie chart comes up first, and then clicking on > the pie chart will display the table. Do you want a new window with the table (look at Toplevel)? Do you want a new area of the window (with the pie chart) to display the table (you can just use pack for this)? The methods for these are different. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From curtis.larsen@Covance.Com Tue Jun 5 15:23:05 2001 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Tue, 05 Jun 2001 09:23:05 -0500 Subject: [Tutor] De-CSV-ing Resolved Message-ID: Thanks to everyone who replied I now have: o A further understanding of exception usage o A nice little function to test with, and o A site that "high-level" explains such algorithms Thanks again! Curtis ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that we can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From MuraleeKrishnanR. Tue Jun 5 18:00:33 2001 From: MuraleeKrishnanR. (MuraleeKrishnanR.) Date: 5 Jun 2001 11:00:33 MDT Subject: [Tutor] Hello Message-ID: <20010605170033.21022.qmail@nwcst313.netaddress.usa.net> Hello all, = This is the first time i am mailing in this list.. i am a beginner in Python programming. I am stuck up somewhere so I thought someone would be able to help me out. The following is the error message when i wrote a program for implementing Tkinter --------------------------------------------- C:\Python21>python gui.py Traceback (most recent call last): File "gui.py", line 3, in ? top =3D Tkinter.Tk() File "c:\python21\lib\lib-tk\Tkinter.py", line 1480, in __init__ self.tk =3D _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {} C:/PYTHON21/lib/tcl8.3 C:/lib/tcl8.3 lib/tcl8.3 lib/tcl8.3/library librar y ../tcl8.3/library This probably means that Tcl wasn't installed properly. ------------------------------------------------------ > Hope someone would help me.. regards, Murali ____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=3D= 1 From cynic@mail.cz Tue Jun 5 20:07:39 2001 From: cynic@mail.cz (Cynic) Date: Tue, 05 Jun 2001 21:07:39 +0200 Subject: [Tutor] Hello In-Reply-To: <20010605170033.21022.qmail@nwcst313.netaddress.usa.net> Message-ID: <5.1.0.14.2.20010605210203.02081e78@mail.cz> No guarantees... Append the directory where init.tcl lives either to $PYTHONPATH or (in the script) to sys.path. At 19:00 5.6. 2001, Muralee Krishnan R. wrote the following: -------------------------------------------------------------- >Hello all, > > This is the first time i am mailing in this list.. > i am a beginner in Python programming. I am stuck up > somewhere so I thought someone would be able to help > me out. > The following is the error message when i wrote a > program for implementing Tkinter > --------------------------------------------- > C:\Python21>python gui.py > Traceback (most recent call last): > File "gui.py", line 3, in ? > top = Tkinter.Tk() > File "c:\python21\lib\lib-tk\Tkinter.py", line 1480, > in __init__ > self.tk = _tkinter.create(screenName, baseName, > className) > TclError: Can't find a usable init.tcl in the > following directories: > {} C:/PYTHON21/lib/tcl8.3 C:/lib/tcl8.3 lib/tcl8.3 > lib/tcl8.3/library librar > y ../tcl8.3/library > > > > This probably means that Tcl wasn't installed > properly. > ------------------------------------------------------ >> > Hope someone would help me.. > >regards, >Murali > >____________________________________________________________________ >Get free email and a permanent address at http://www.netaddress.com/?N=1 > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor ------end of quote------ cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7 From _cardiac_@yahoo.com Tue Jun 5 22:02:11 2001 From: _cardiac_@yahoo.com (CARDIAC ARREST) Date: Tue, 5 Jun 2001 14:02:11 -0700 (PDT) Subject: [Tutor] (no subject) Message-ID: <20010605210211.926.qmail@web13901.mail.yahoo.com> I need some more simple instructions on learning to program with python ... the only programming i know is VERY basic html .. some of the things that are writen a just cant understand .. i dont want to know how to do 2+2 etc i wanna know how to make something i know this is part of the 1st steps but __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From brett@earthlight.co.nz Tue Jun 5 22:10:05 2001 From: brett@earthlight.co.nz (Brett Shand) Date: Wed, 6 Jun 2001 09:10:05 +1200 Subject: [Tutor] (no subject) In-Reply-To: <20010605210211.926.qmail@web13901.mail.yahoo.com> Message-ID: <3B1DF36D.22407.381D006@localhost> I am in a somewhat similar situation. I am using "Learning Python" by Lutz and Ascher. I recommend it very highly. You can get more information here: http://www.oreilly.com/catalog/lpython/ brett --------------------------------------------- On 5 Jun 2001, at 14:02, CARDIAC ARREST wrote: > I need some more simple instructions on learning to > program with python ... the only programming i know is > VERY basic html .. some of the things that are writen > a just cant understand .. i dont want to know how to > do 2+2 etc i wanna know how to make something i know > this is part of the 1st steps but > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail - only $35 > a year! http://personal.mail.yahoo.com/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From _cardiac_@yahoo.com Tue Jun 5 22:14:48 2001 From: _cardiac_@yahoo.com (CARDIAC ARREST) Date: Tue, 5 Jun 2001 14:14:48 -0700 (PDT) Subject: [Tutor] (no subject) Message-ID: <20010605211448.6518.qmail@web13905.mail.yahoo.com> ok i dont think i was detialed enough in the last message i was frustrated :P anyway what im trying to find is like a program example icq something that is made with mostly or all python that i can see the code and build on it i learn best by watching/ looking then doing if someone gave me the code to example icq or something complex i code write it line by line then see how it comes together if someone has a program like this that i could use i will sign a agreement or whatever that i wont try to sell it or all that junk i just want to LEARN!!! HELP PLEASE!!! Thank you all __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From kauphlyn@speakeasy.org Tue Jun 5 22:56:28 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Tue, 5 Jun 2001 14:56:28 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <20010605211448.6518.qmail@web13905.mail.yahoo.com> Message-ID: You might find some interesting stuff on http://www.lowerstandard.com/python/pythonsource.html On Tue, 5 Jun 2001, CARDIAC ARREST wrote: > ok i dont think i was detialed enough in the last > message i was frustrated :P anyway what im trying to > find is like a program example icq something that > is made with mostly or all python that i can see the > code and build on it i learn best by watching/ looking > then doing if someone gave me the code to example icq > or something complex i code write it line by line > then see how it comes together if someone has a > program like this that i could use i will sign a > agreement or whatever that i wont try to sell it or > all that junk i just want to LEARN!!! HELP PLEASE!!! > > Thank you all > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail - only $35 > a year! http://personal.mail.yahoo.com/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From rob@jam.rr.com Tue Jun 5 22:09:02 2001 From: rob@jam.rr.com (Rob Andrews) Date: Tue, 5 Jun 2001 16:09:02 -0500 Subject: [Tutor] (no subject) References: <20010605210211.926.qmail@web13901.mail.yahoo.com> Message-ID: <002501c0ee03$d78c90c0$de00a8c0@planhouse5> ----- Original Message ----- From: "CARDIAC ARREST" <_cardiac_@yahoo.com> To: Sent: Tuesday, June 05, 2001 4:02 PM Subject: [Tutor] (no subject) > I need some more simple instructions on learning to > program with python ... the only programming i know is > VERY basic html .. some of the things that are writen > a just cant understand .. i dont want to know how to > do 2+2 etc i wanna know how to make something i know > this is part of the 1st steps but > No problem! There are a number of good tutorials on the web, and here's a page with links to a good number of them: http://www.lowerstandard.com/python/tutoriallinks.html Rob Useless Python It's not just for breakfast anymore! http://www.lowerstandard.com/python/index.html From phil@xfr.co.uk Tue Jun 5 23:11:07 2001 From: phil@xfr.co.uk (Philip Kilner) Date: Tue, 05 Jun 2001 23:11:07 +0100 Subject: [Tutor] (no subject) In-Reply-To: <20010605211448.6518.qmail@web13905.mail.yahoo.com> References: <20010605211448.6518.qmail@web13905.mail.yahoo.com> Message-ID: Hello, In article <20010605211448.6518.qmail@web13905.mail.yahoo.com>, Cardiac Arrest wrote: > like a program example icq something that > is made with mostly or all python that i can see the > code and build on it I'm nowhere near that level of complexity, but I can help you find Python resources. For ICQ-type applications, I took a look at:- http://www.jabber.org - and there is indeed a Python tool (Python/Gnome actually). It's at:- http://pybber.sourceforge.net/ There's also an AIM (AOL IM) client at:- http://www.z3p.f2s.com/download/code/toc.py (Pulls up source in browser!) I found this for you in the Vaults of Parnassus;- http://www.vex.net/parnassus/ This is the first place I would look for downloadable python apps with source - but I'd be looking for something simpler... I don't know if any of the IM resources are any good - I'm just trying to help you find stuff - but Parnassus is a fabulous resource. HTH, PhilK From python.tutorial@jarava.org Wed Jun 6 00:57:04 2001 From: python.tutorial@jarava.org (Javier JJ) Date: Wed, 6 Jun 2001 01:57:04 +0200 Subject: [Tutor] Access to Windows Timers / Idle "states"?? Message-ID: <006901c0ee1b$39375870$0124a8c0@uno> Hi all!! After some "lurking" on the list (and not too much time to program, either :-) I've decided to jump with both feet in :-) I'm trying to make a program that can handle "timers" (ie, set a timer for "x" seconds later) and / or "register" itself to recieve windows events. The idea is, when I launch this program, I want to be able to set a certain amount of time after whihc I want my program to do something (namely, kill another program :-) At the moment, the "killing another program" would be handled with the pslist and pskill utils from sysinternals, so I "only" want to be able to set a timer... Alternatively, I'd like to be able to "know" when the "idle" process kicks in, like to know when the countdown for the screensaver starts.... The thing is, I have a program that every now and then locks itself solid and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work, even though the OS "seems" to be getting the keys, and the mouse cursor moves). So, I'd like to be able to "sense" when the OS hasn't been getting any imput (keys / mouse) for a set period of time and, if that happens, it'll just kill the offending process.... Am I making any sense at all? Any and all help would be greatly appreciated. TIA Javier ---- Hm..what's this red button fo:=/07 A big THANK YOU for the replies i have got from my post i wasnt sure about doing it but im glad i did thank you all again!!! __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From ak@silmarill.org Wed Jun 6 01:30:50 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Tue, 05 Jun 2001 20:30:50 -0400 Subject: [Tutor] Access to Windows Timers / Idle "states"?? In-Reply-To: <"from python.tutorial"@jarava.org> References: <006901c0ee1b$39375870$0124a8c0@uno> Message-ID: <20010605203050.A24683@sill.silmarill.org> On Wed, Jun 06, 2001 at 01:57:04AM +0200, Javier JJ wrote: > Hi all!! > > After some "lurking" on the list (and not too much time to program, either > :-) I've decided to jump with both feet in :-) > > I'm trying to make a program that can handle "timers" (ie, set a timer for > "x" seconds later) and / or "register" itself to recieve windows events. > > The idea is, when I launch this program, I want to be able to set a certain > amount of time after whihc I want my program to do something (namely, kill > another program :-) > > At the moment, the "killing another program" would be handled with the > pslist and pskill utils from sysinternals, so I "only" want to be able to > set a timer... > > Alternatively, I'd like to be able to "know" when the "idle" process kicks > in, like to know when the countdown for the screensaver starts.... > > The thing is, I have a program that every now and then locks itself solid > and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work, > even though the OS "seems" to be getting the keys, and the mouse cursor > moves). So, I'd like to be able to "sense" when the OS hasn't been getting > any imput (keys / mouse) for a set period of time and, if that happens, > it'll just kill the offending process.... > > Am I making any sense at all? Sort of :-). I don't use windows anymore, so I can only help with the timer thing.. the command for it is time.sleep(5) to sleep for 5 seconds. If you want to set hours or minutes, the way to do so is this: time.sleep(60*60*3.5) for 3.5 hours, for instance. Also, you have time.time() which gives you current time in seconds from the start of epoch (~1970). Anyway, in order for timer to work, here's what you can do: sense_keypress() time.sleep(60) if not keypresses_happened(): os.kill(someprog) Look at docs for os.kill. time.time() you can use to tell how long something took, like this: t = time.time() do_something() print 'do_something() took %d seconds' % (time.time() - t) > > Any and all help would be greatly appreciated. > > TIA > > Javier > > ---- > > Hm..what's this red button fo:=/07 > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Lucifer Sam Siam cat Always sitting by your side Always by your side That cat's something I can't explain - Syd From dsh8290@rit.edu Wed Jun 6 03:24:53 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 5 Jun 2001 22:24:53 -0400 Subject: [Tutor] Access to Windows Timers / Idle "states"?? In-Reply-To: <006901c0ee1b$39375870$0124a8c0@uno>; from python.tutorial@jarava.org on Wed, Jun 06, 2001 at 01:57:04AM +0200 References: <006901c0ee1b$39375870$0124a8c0@uno> Message-ID: <20010605222453.B14318@harmony.cs.rit.edu> On Wed, Jun 06, 2001 at 01:57:04AM +0200, Javier JJ wrote: ... | The thing is, I have a program that every now and then locks itself solid | and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work, | even though the OS "seems" to be getting the keys, and the mouse cursor | moves). I've seen this with win2k also. Sometimes it is the OS's own fault as it tries to shutdown (though sometimes I wonder if it is really trying ...) | So, I'd like to be able to "sense" when the OS hasn't been getting | any imput (keys / mouse) for a set period of time and, if that | happens, it'll just kill the offending process.... | | Am I making any sense at all? Yes -- you want to prevent your OS from locking up (IOW failing to meet its requirements). The solution is much simpler : use Debian! Sorry, not much help with the code, but I don't try and fix windows by writing my own watchdog timer and am not sure how you would do that reliably. -D From dyoo@hkn.eecs.berkeley.edu Wed Jun 6 07:53:38 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 5 Jun 2001 23:53:38 -0700 (PDT) Subject: [Tutor] Converting problem sets from other languages into Python? Message-ID: Hiya everyone, A while back, some people asked for sample problems that they could do to test out their fluency in Python. Usually, self-motivated projects are idea at letting people make their knowledge relevant, but sometimes, people don't know where to start! Perhaps we should also provide a small "problem set" repository. Sorta like mini-exercises, with some hints at how to approach a problem. Useless Python already does a little bit of this with its Python Challenges at: http://www.lowerstandard.com/python/pythonchallenge.html and perhaps this can be extended with more problems. In short: why not stea... er... convert problems from some textbooks to make them Python-relevant? By providing these practical problems, we'd let people gain more confidence as they find they can do these things. Extending "Useless Python", we can have "Useless Python Problems". *grin* I have a few problems written in Scheme, which I should be able to convert into Python: http://hkn.eecs.berkeley.edu/~dyoo/cs3/doublets.pdf http://hkn.eecs.berkeley.edu/~dyoo/cs3/wordprocessing.pdf (which have too much of a CS flavor, admittedly, but I have to start somewhere.) What do people think? From wheelege@tsn.cc Wed Jun 6 08:45:39 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 6 Jun 2001 17:45:39 +1000 Subject: [Tutor] Converting problem sets from other languages into Python? References: Message-ID: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> > <...> > > What do people think? > Great idea! Some good all-round computer problems can be found at http://www.cse.unsw.edu.au/progcomp - just click on the links to see the problems for the various years (the grand final ones are particularly fun :). Glen. From wheelege@tsn.cc Wed Jun 6 09:41:18 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 6 Jun 2001 18:41:18 +1000 Subject: [Tutor] Recursion Message-ID: <021401c0ee64$75b65dc0$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_0211_01C0EEB8.4655DFC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey all, While fiddling around with maths, I thought it would be nice and cool = to get all the possible permutations of a set, taken n at a time. I = have been trying to get this to work nicely, but I'm just not familiar = enough with recursion to get it to behave. For example, if I wanted to get all the permutations of a set = ['a','b'] taken three at a time, I would write this : >>> c =3D [] >>> s =3D ['a', 'b'] >>> for i1 in range(len(s)): ... for i2 in range(len(s)): ... for i3 in range(len(s)): ... c.append([s[i1], s[i2], s[i3]]) ...=20 >>> for item in c: print item ...=20 ['a', 'a', 'a'] ['a', 'a', 'b'] ['a', 'b', 'a'] ['a', 'b', 'b'] ['b', 'a', 'a'] ['b', 'a', 'b'] ['b', 'b', 'a'] ['b', 'b', 'b'] Which is all well and good, but when I want to take them n at a time I = need more for loops. Thus I thought 'Hmmm, I could get a function which = calls itself n times...that would work!' - but I'm just too green with = this sort of programming for it to happen for me. Help? Thanks, Glen. ------=_NextPart_000_0211_01C0EEB8.4655DFC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
  Hey all,
 
  While fiddling around with maths, I thought it would be nice = and=20 cool to get all the possible permutations of a set, taken n at a = time.  I=20 have been trying to get this to work nicely, but I'm just not familiar = enough=20 with recursion to get it to behave.
  For example, if I wanted to get all the permutations of = a set=20 ['a','b'] taken three at a time, I would write this :
 
>>> c =3D []
>>> s =3D ['a', = 'b']
>>> for i1=20 in range(len(s)):
...  for i2 in range(len(s)):
... =   for=20 i3 in range(len(s)):
...    c.append([s[i1], s[i2],=20 s[i3]])
...
>>> for item in c: print item
... =
['a', 'a',=20 'a']
['a', 'a', 'b']
['a', 'b', 'a']
['a', 'b', 'b']
['b', = 'a',=20 'a']
['b', 'a', 'b']
['b', 'b', 'a']
['b', 'b', 'b']
  Which is all well and good, but when I want to take them n = at a time=20 I need more for loops.  Thus I thought 'Hmmm, I could get a = function which=20 calls itself n times...that would work!' - but I'm just too green = with this=20 sort of programming for it to happen for me.
  Help?
 
  Thanks,
  Glen.
------=_NextPart_000_0211_01C0EEB8.4655DFC0-- From scarblac@pino.selwerd.nl Wed Jun 6 10:28:03 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 6 Jun 2001 11:28:03 +0200 Subject: [Tutor] Recursion In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Jun 06, 2001 at 06:41:18PM +1000 References: <021401c0ee64$75b65dc0$0200a8c0@ACE> Message-ID: <20010606112803.A19167@pino.selwerd.nl> On 0, Glen Wheeler wrote: > Hey all, > > While fiddling around with maths, I thought it would be nice and cool to get all the possible permutations of a set, taken n at a time. I have been trying to get this to work nicely, but I'm just not familiar enough with recursion to get it to behave. > For example, if I wanted to get all the permutations of a set ['a','b'] taken three at a time, I would write this : > > >>> c = [] > >>> s = ['a', 'b'] > >>> for i1 in range(len(s)): > ... for i2 in range(len(s)): > ... for i3 in range(len(s)): > ... c.append([s[i1], s[i2], s[i3]]) > ... > >>> for item in c: print item > ... > ['a', 'a', 'a'] > ['a', 'a', 'b'] > ['a', 'b', 'a'] > ['a', 'b', 'b'] > ['b', 'a', 'a'] > ['b', 'a', 'b'] > ['b', 'b', 'a'] > ['b', 'b', 'b'] > > Which is all well and good, but when I want to take them n at a time I > need more for loops. Thus I thought 'Hmmm, I could get a function which > calls itself n times...that would work!' - but I'm just too green with this > sort of programming for it to happen for me. The way to think about recursion is solving the problem by solving a smaller version of the problem first, until you get a smaller problem that's easy to solve. In this case, the reasoning goes something like this: You can get all the permutations of a list by taking each element in turn, and then add to that element all the permutations of the *rest* of the list. That rest is smaller than the list itself. And the problem is trivial for a list of length 1 or 0. So we can use recursion. We get something like this: def permutations(L): result = [] if len(L) <= 1: # The single result is the list itself result.append(L[:]) else: for i in range(len(L)): # We pick element i, and combine it with the permutations of the rest rest = L[:i] + L[i+1:] for permutation in permutations(rest): result.append([L[i]]+permutation) return result -- Remco Gerlich From dyoo@hkn.eecs.berkeley.edu Wed Jun 6 10:35:31 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 6 Jun 2001 02:35:31 -0700 (PDT) Subject: [Tutor] Recursion In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE> Message-ID: On Wed, 6 Jun 2001, Glen Wheeler wrote: > For example, if I wanted to get all the permutations of a set > ['a','b'] taken three at a time, I would write this : > > >>> c = [] > >>> s = ['a', 'b'] > >>> for i1 in range(len(s)): > ... for i2 in range(len(s)): > ... for i3 in range(len(s)): > ... c.append([s[i1], s[i2], s[i3]]) > ... > >>> for item in c: print item > ... > ['a', 'a', 'a'] > ['a', 'a', 'b'] > ['a', 'b', 'a'] > ['a', 'b', 'b'] > ['b', 'a', 'a'] > ['b', 'a', 'b'] > ['b', 'b', 'a'] > ['b', 'b', 'b'] > > Which is all well and good, but when I want to take them n at a time > I need more for loops. Thus I thought 'Hmmm, I could get a function > which calls itself n times...that would work!' - but I'm just too > green with this sort of programming for it to happen for me. Hello Glen! To see the recursion, we should look at some small cases of the problem first. As background for the others: the idea of recursion is to see a relationship between the "big" version of a problem and a slightly smaller version. By seeing this relationship, we may be able to solve the big problem by taking advantage of the solution for the small one. In this problem, we're measuring bigness by 'n at a time'. The bigger 'n' gets, the larger the problem. Let's take a really close look at what the program should do when n is equal to 1, 2, and 3. Once we do this, things might look clearer (or more blurry, depending on how long we strain our eyes... *grin*) We know that taking the one_at_a_time() on this list ['a', 'b'] should look like: [ ['a'], ['b'] ] Let's pretend we have that function to play with. We can imagine what the result of two_at_a_time() looks like: [ ['a', 'a'], ['a', 'b'], ['b', 'a'], ['b', 'b'] ] I'm intensionally printing two_at_a_time()'s result in 2 visually distinct blocks because, if we look at this for a little bit, we might see a small pattern. In order to get two_at_a_time(), all we need to do is take every element in one_at_a_time, and plunk either 'a' or 'b' in front. This can be written as: ### def two_at_a_time(L): source = one_at_a_time(L) c = [] for x in L: for s in source: c.append([x] + s) ### Ok, let's look at three_at_a_time() and see if there's a relationship between it and two_at_a_time: [ ['a', 'a', 'a'], ['a', 'a', 'b'], ['a', 'b', 'a'], ['a', 'b', 'b'], ['b', 'a', 'a'], ['b', 'a', 'b'], ['b', 'b', 'a'], ['b', 'b', 'b'], ] Same idea: let's use two_at_a_time() to solve three_at_a_time()! The definition for three_at_a_time() will eerily familiar... ### def three_at_a_time(L): source = two_at_a_time(L) c = [] for x in L: for s in source: c.append([x] + s) ### This should give you enough to write n_at_a_time(). If you have any questions, please feel free to ask. Good luck! From scarblac@pino.selwerd.nl Wed Jun 6 10:38:36 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 6 Jun 2001 11:38:36 +0200 Subject: [Tutor] Recursion In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Jun 06, 2001 at 06:41:18PM +1000 References: <021401c0ee64$75b65dc0$0200a8c0@ACE> Message-ID: <20010606113836.A19201@pino.selwerd.nl> On 0, Glen Wheeler wrote: > Hey all, > > While fiddling around with maths, I thought it would be nice and cool to get all the possible permutations of a set, taken n at a time. I have been trying to get this to work nicely, but I'm just not familiar enough with recursion to get it to behave. > For example, if I wanted to get all the permutations of a set ['a','b'] taken three at a time, I would write this : > > >>> c = [] > >>> s = ['a', 'b'] > >>> for i1 in range(len(s)): > ... for i2 in range(len(s)): > ... for i3 in range(len(s)): > ... c.append([s[i1], s[i2], s[i3]]) > ... > >>> for item in c: print item > ... > ['a', 'a', 'a'] > ['a', 'a', 'b'] > ['a', 'b', 'a'] > ['a', 'b', 'b'] > ['b', 'a', 'a'] > ['b', 'a', 'b'] > ['b', 'b', 'a'] > ['b', 'b', 'b'] Wait. In my other mail, I solved the wrong problem :-) I read 'permutations' and stopped reading. You want to make lists of length n with elements taking from a list L; again, solve it by making all the lists of length n-1, where length 0 is trivial, and combine them with all the possible elements: def permutations2(L, n): # What's the proper name for this, anyway? if n == 0: return [[]] result = [] # Compute this outside the loop smaller_lists = permutations2(L, n-1) for element in L: for l in smaller_lists: result.append([element]+l) return result (untested) -- Remco Gerlich From dyoo@hkn.eecs.berkeley.edu Wed Jun 6 10:41:30 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 6 Jun 2001 02:41:30 -0700 (PDT) Subject: [Tutor] Recursion In-Reply-To: Message-ID: On Wed, 6 Jun 2001, Daniel Yoo wrote: > ### > def two_at_a_time(L): > source = one_at_a_time(L) > c = [] > for x in L: > for s in source: > c.append([x] + s) > ### Oops. Ok, I need to make a correction of a very silly bug: ### def two_at_a_time(L): source = one_at_a_time(L) c = [] for x in L: for s in source: c.append([x] + s) return c ### The program I wrote did all this neat work, but it never gave the answer back to us! Ugh. Same bug with three_at_a_time(). Sorry about that. From wheelege@tsn.cc Wed Jun 6 10:58:47 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 6 Jun 2001 19:58:47 +1000 Subject: [Tutor] Recursion References: <021401c0ee64$75b65dc0$0200a8c0@ACE> <20010606113836.A19201@pino.selwerd.nl> Message-ID: <023b01c0ee6f$4870b3a0$0200a8c0@ACE> Thanks Daniel for the great explanation+thought process, and Remco for inadverdently answering two questions. You two surely are a very effective one-two in this list :) Thanks again, Glen. From Eugene.Leitl@lrz.uni-muenchen.de Wed Jun 6 11:29:05 2001 From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl) Date: Wed, 6 Jun 2001 12:29:05 +0200 (MET DST) Subject: [Tutor] parsing a blank-separated string into a list Message-ID: Assuming, I have a string like this (produced by the JME applet, encoding a molecule I entered): 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1 And want to turn it into a list like this: [10, 11, C, 9.13 ... ] How do I do it? jmelist = map(None, jmevalue) produces [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms. Is there an idiom for that? (I mean, it's of course possible to do it by hand, but it's not Python Zen). From SBrunning@trisystems.co.uk Wed Jun 6 11:51:22 2001 From: SBrunning@trisystems.co.uk (Simon Brunning) Date: Wed, 6 Jun 2001 11:51:22 +0100 Subject: [Tutor] parsing a blank-separated string into a list Message-ID: <31575A892FF6D1118F5800600846864D78BCEA@intrepid> > From: Eugene Leitl [SMTP:Eugene.Leitl@lrz.uni-muenchen.de] > Assuming, I have a string like this (produced by the JME applet, > encoding a molecule I entered): > > 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C > 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 > 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1 > > And want to turn it into a list like this: > > [10, 11, C, 9.13 ... ] > > How do I do it? > > jmelist = map(None, jmevalue) produces > > [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms. Try this mystring = '''10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1''' mylist = mystring.split() At this point, mylist consists of a list of strings. It looks like you want the numeric strings converted into numbers. Floats by the look of it. Now, if your strings were *all* numeric, you could do: mylist = [float(value) for value in mylist] and you would be fine. List comprehensions are nice. ;-) But in your case, this would blow up with a ValueError when trying to convert the alphabetic characters, so we'll have to do this the old fashioned way: for index in range(len(mylist)): try: mylist[index] = float(mylist[index]) except ValueError: pass BTW, if you are not familiar with floats, you have a lot of surprises coming up. If you are, then you *still* have a lot of surprises coming up. ;-) HTH, Simon B. ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From rob@jam.rr.com Wed Jun 6 12:11:51 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 06 Jun 2001 06:11:51 -0500 Subject: [Tutor] Converting problem sets from other languages into Python? References: Message-ID: <3B1E0FF7.DD2600D6@jam.rr.com> Daniel Yoo wrote: > > Hiya everyone, > > A while back, some people asked for sample problems that they could do to > test out their fluency in Python. Usually, self-motivated projects are > idea at letting people make their knowledge relevant, but sometimes, > people don't know where to start! > > Perhaps we should also provide a small "problem set" repository. Sorta > like mini-exercises, with some hints at how to approach a problem. > Useless Python already does a little bit of this with its Python > Challenges at: > > http://www.lowerstandard.com/python/pythonchallenge.html > > and perhaps this can be extended with more problems. > > In short: why not stea... er... convert problems from some textbooks to > make them Python-relevant? By providing these practical problems, we'd > let people gain more confidence as they find they can do these things. > Extending "Useless Python", we can have "Useless Python Problems". > *grin* > > I have a few problems written in Scheme, which I should be able to convert > into Python: > > http://hkn.eecs.berkeley.edu/~dyoo/cs3/doublets.pdf > http://hkn.eecs.berkeley.edu/~dyoo/cs3/wordprocessing.pdf > > (which have too much of a CS flavor, admittedly, but I have to start > somewhere.) > > What do people think? > This is just the sort of thing I had in mind. I'd thought of swip^^^^converting some of the problems from my books on other languages, partly so I could figure out how to actually get them accomplished in Python (which is easier) so I'd have a frame of reference on how do do them in the other languages. But I think the bottom line is that newbies, teachers, and other people interested in the Python learning process NEED good CS-type problems and some proposed solutions. I believe that every ACM problem we can solve in Python, and every good classical or practical problem we can do it with, will help us learn the language and add significantly to the Python legacy. Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From rob@jam.rr.com Wed Jun 6 12:15:15 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 06 Jun 2001 06:15:15 -0500 Subject: [Tutor] Recursion References: <021401c0ee64$75b65dc0$0200a8c0@ACE> <20010606113836.A19201@pino.selwerd.nl> <023b01c0ee6f$4870b3a0$0200a8c0@ACE> Message-ID: <3B1E10C3.342CF072@jam.rr.com> Glen Wheeler wrote: > > Thanks Daniel for the great explanation+thought process, and Remco for > inadverdently answering two questions. > You two surely are a very effective one-two in this list :) > > Thanks again, > Glen. > A few of us in Mississippi still suspect that Danny and Remco are actually sophisticated bot scripts that Guido brought back from the future in his time machine. Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From steve@mercury.in.cqsl.com Wed Jun 6 11:56:41 2001 From: steve@mercury.in.cqsl.com (lonetwin@yahoo.com) Date: Wed, 6 Jun 2001 16:26:41 +0530 (IST) Subject: [Tutor] parsing a blank-separated string into a list In-Reply-To: Message-ID: On Wed, 6 Jun 2001, Eugene Leitl wrote: >10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C >8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 >1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1 > >And want to turn it into a list like this: > >[10, 11, C, 9.13 ... ] > >How do I do it? >>>import string >>> p = '10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C ...' >>> string.split(p) ['10', '11', 'C', '9.13', '-8.85', 'C', '10.34', '-8.15', 'C', '7.92', '-8.15', 'C', '10.34', '-6.75', 'C', '...'] :) if u have python 2.0, don't import string, just do a p.split() Peace Steve -- |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##|| |||/\##|||||||||##/\|| |/ \#########/ \ |\ \#######/ / ||\____/#######\____/| ===================================== Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! ==================================== From rob@jam.rr.com Wed Jun 6 12:44:46 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 06 Jun 2001 06:44:46 -0500 Subject: [Tutor] Converting problem sets from other languages into Python? References: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> Message-ID: <3B1E17AE.523862B4@jam.rr.com> Glen Wheeler wrote: > > > <...> > > > > What do people think? > > > > Great idea! > > Some good all-round computer problems can be found at > http://www.cse.unsw.edu.au/progcomp - just click on the links to see the > problems for the various years (the grand final ones are particularly fun > :). > > Glen. > Superlative, Glen! I've added this material to the list of programming contest problem links on the appropriate Useless page: http://www.lowerstandard.com/python/acmcontest.html While we're kinda on the subject, I'll go ahead and leak an up-coming feature for Useless. (First I need to finish the program that will automatically generate the HTML pages, but I'm mostly there.) Once it's begun, for each script someone contributes to Useless, the contributor will be able to add an icon to a script by someone else, indicating one of several things ("I actually used this", "I learned something from this", "This is indeed Useless", etc.). But for each programming contest or Python Challenge solution, the contributor will receive two of these. Aside from adding some humor and interesting commentary to the scripts, I'm hoping this will encourage budding coders to share their gifts more. Okay, I'm done now, Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From wheelege@tsn.cc Wed Jun 6 12:59:20 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 6 Jun 2001 21:59:20 +1000 Subject: [Tutor] Converting problem sets from other languages into Python? References: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> Message-ID: <029701c0ee80$1fba46e0$0200a8c0@ACE> > Superlative, Glen! I've added this material to the list of programming > contest problem links on the appropriate Useless page: > > http://www.lowerstandard.com/python/acmcontest.html > Thanks. I just went to investigate what you added, and noticed that only the sample problems are there - if you link to the parent page (http://www.cse.unsw.edu.au/~progcomp/) then there are actually links to a very many more problems. Also from this page are the links to the much more entertaining grand final problems. These links are under the heading 'ProgComp in past years', it's on the right of the page near the bottom. The ones your linked to now actually have worked solutions written out for them, wheras the others don't (yet). > While we're kinda on the subject, I'll go ahead and leak an up-coming > feature for Useless. (First I need to finish the program that will > automatically generate the HTML pages, but I'm mostly there.) > If you need help... :) > Once it's begun, for each script someone contributes to Useless, the > contributor will be able to add an icon to a script by someone else, > indicating one of several things ("I actually used this", "I learned > something from this", "This is indeed Useless", etc.). But for each > programming contest or Python Challenge solution, the contributor will > receive two of these. Aside from adding some humor and interesting > commentary to the scripts, I'm hoping this will encourage budding coders > to share their gifts more. > Sounds like an excellent idea! I won't be able to hold back my flood of scripts then :) Glen. > Okay, I'm done now, > Rob From rob@jam.rr.com Wed Jun 6 13:15:16 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 06 Jun 2001 07:15:16 -0500 Subject: [Tutor] Converting problem sets from other languages into Python? References: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> <029701c0ee80$1fba46e0$0200a8c0@ACE> Message-ID: <3B1E1ED4.F2B89880@jam.rr.com> Glen Wheeler wrote: > > > Superlative, Glen! I've added this material to the list of programming > > contest problem links on the appropriate Useless page: > > > > http://www.lowerstandard.com/python/acmcontest.html > > > > Thanks. I just went to investigate what you added, and noticed that only > the sample problems are there - if you link to the parent page > (http://www.cse.unsw.edu.au/~progcomp/) then there are actually links to a > very many more problems. Also from this page are the links to the much more > entertaining grand final problems. These links are under the heading > 'ProgComp in past years', it's on the right of the page near the bottom. > The ones your linked to now actually have worked solutions written out for > them, wheras the others don't (yet). > Thanks for catching that, Glen. My error has been remedied now. That's what I get for pre-coffee web maintenance, Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From python.tutorial@jarava.org Wed Jun 6 14:10:05 2001 From: python.tutorial@jarava.org (Javier JJ) Date: Wed, 6 Jun 2001 15:10:05 +0200 Subject: [Tutor] Access to Windows Timers / Idle "states"?? References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605222453.B14318@harmony.cs.rit.edu> Message-ID: <007d01c0ee8a$018b5560$0124a8c0@uno> > | The thing is, I have a program that every now and then locks itself solid > | and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work, > | even though the OS "seems" to be getting the keys, and the mouse cursor > | moves). > > I've seen this with win2k also. Sometimes it is the OS's own fault as > it tries to shutdown (though sometimes I wonder if it is really trying > ...) MM... Personally, I've only experienced this on programs that run fullscreen and "take over" the display, like the program on my WinTV card, Games.... it's probably something to do with DirectX or similar... and that's a beast I won't touch with a 10 meter pole :) So, as the OS seems to be "receiving" input still (sometimes - not always- I've been able to ctrl-alt-del, open the the task manager and kill the beast), I was wondering about how to "build my own watchdog timer" :-)) > | So, I'd like to be able to "sense" when the OS hasn't been getting > | any imput (keys / mouse) for a set period of time and, if that > | happens, it'll just kill the offending process.... > | > | Am I making any sense at all? > > Yes -- you want to prevent your OS from locking up (IOW failing to Welll. it's not really (at least it doesn't seem) like it's really frozen solid.. only that the screen is and not all inputs are handled.. but the network and services go on (eprompter keeps checking the mail, etc). I had wondered about another solution: building a xmlrpc or similar server that would let me "kill" the offending process when triggered from another machine. Buy having the two computers on is something I'd rather avoid :-)) > meet its requirements). The solution is much simpler : use Debian! Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found HlafLife - Front Line Force for Linux .... and besides, I don't think I could switch to linux and be 100% productive as of yet .... > Sorry, not much help with the code, but I don't try and fix windows by > writing my own watchdog timer and am not sure how you would do > that reliably. Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses to signal "no activity" (ie, the same ones that the OS uses to know when to fire the screensaver), that'd be fairly simple to do. .. Thanks for the idea, though. I'll look into watchdogs :-)) Javier ---- Famous last words - Don't worry, I can handle it. From python.tutorial@jarava.org Wed Jun 6 14:25:09 2001 From: python.tutorial@jarava.org (Javier JJ) Date: Wed, 6 Jun 2001 15:25:09 +0200 Subject: [Tutor] Access to Windows Timers / Idle "states"?? References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605203050.A24683@sill.silmarill.org> Message-ID: <009f01c0ee8c$1bf55930$0124a8c0@uno> > > > > Am I making any sense at all? > > Sort of :-). I don't use windows anymore, so I can only help with the timer > thing.. the command for it is time.sleep(5) to sleep for 5 seconds. If you want > to set hours or minutes, the way to do so is this: time.sleep(60*60*3.5) for 3.5 > hours, for instance. Also, you have time.time() which gives you current time in > seconds from the start of epoch (~1970). That's really the way :-)) I only need to delay an action a set amount of time, nothing really fancy (I know if I had to sichronize serveral things, then I'd have to "really" build a timer to use a "general" event", But for what I need, time.sleep probably will fit nicely :-) > Anyway, in order for timer to work, here's what you can do: > > sense_keypress() I guess the trick is here :-) I'll have to build this function.... the trick is how, I guess :-)) > time.sleep(60) > if not keypresses_happened(): > os.kill(someprog) > > Look at docs for os.kill. Will do :-) Pity is, "avaliability: UNIX".That's what I "Love" about "pskill" form sysinternals... it's like kill, only for windows :-) > time.time() you can use to tell how long something took, like this: > > t = time.time() > do_something() > print 'do_something() took %d seconds' % (time.time() - t) > Thanks a lot for the help :-) Javier ---- Famous last words - Don't worry, I can handle it. From Eugene.Leitl@lrz.uni-muenchen.de Wed Jun 6 14:45:12 2001 From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl) Date: Wed, 6 Jun 2001 15:45:12 +0200 (MET DST) Subject: [Tutor] parsing a blank-separated string into a list In-Reply-To: <31575A892FF6D1118F5800600846864D78BCEA@intrepid> Message-ID: On Wed, 6 Jun 2001, Simon Brunning wrote: > Try this > > mystring = '''10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C > 7.92 -6.75 C 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 > -6.05 1 2 2 1 3 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 > 1''' > mylist = mystring.split() Thanks, but I'm stuck with 1.5.2, as 2.1 wouldn't build correctly (can't do freezing, and too dumb to get the configuration right, as the build procedure has changed with 2.1) on the AIX box I'm developing for. Hence I'll stick to the suggestion of the other poster: import string jmelist = string.split(jmevalue) Which works for 1.5.2. Yay! > At this point, mylist consists of a list of strings. It looks like you want > the numeric strings converted into numbers. Floats by the look of it. Now, Usually a good guess, but not in this case. See below. > if your strings were *all* numeric, you could do: > > mylist = [float(value) for value in mylist] > > and you would be fine. List comprehensions are nice. ;-) > > But in your case, this would blow up with a ValueError when trying to > convert the alphabetic characters, so we'll have to do this the old > fashioned way: > > for index in range(len(mylist)): > try: > mylist[index] = float(mylist[index]) > except ValueError: > pass > > BTW, if you are not familiar with floats, you have a lot of surprises coming > up. If you are, then you *still* have a lot of surprises coming up. ;-) Oh, I'm familiar with them, I used to do numerics on big boxes, at least as a user. Any "surprises" will be contained by me not processing the float information. All I need to do is to rearrange the jme string into a mol type: 5 6 C 8.76 -3.88 C 8.06 -5.09 C 5.96 -3.88 C 6.66 -2.66 C 7.36 -3.88 1 2 1 1 5 1 2 5 1 3 4 1 3 5 1 4 5 1 to: 5 6 0 0 0 0 0 0 0 0 1 V2000 8.7600 -3.8800 0.0000 C 0 0 0 0 0 0 8.0600 -5.0900 0.0000 C 0 0 0 0 0 0 5.9600 -3.8800 0.0000 C 0 0 0 0 0 0 6.6600 -2.6600 0.0000 C 0 0 0 0 0 0 7.3600 -3.8800 0.0000 C 0 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 5 1 0 0 0 3 4 1 0 0 0 3 5 1 0 0 0 4 5 1 0 0 0 M END It is a stupid format, but I don't have a choice. I'll post the subroutine when I'm done, could be useful for some folks. -- Eugene Leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From toodles@yifan.net Wed Jun 6 15:18:14 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Wed, 6 Jun 2001 22:18:14 +0800 Subject: [Tutor] List mimicing Message-ID: Hi folks, I'm creating a class somewhat like shelve that stores a list as a file, and provides a very list-like interface to it. I'm having troubles with __iadd__ and __imul__ however. When I call them, it deletes everything in my file...if someone has enough time to go through my code, I would be _very_ appreciative. I'll delete the irrelevant parts to make it quicker/easier Here's what i did to test __iadd__, __imul__ reacts the same way: >>> import file >>> x=file.ListShelf('a') >>> x.get() >>> x+=[1,2,3] >>> x.get() Traceback (most recent call last): File "", line 1, in ? x.get() AttributeError: 'None' object has no attribute 'get' >>> print x None Thanks, Andrew -------- code ---------- import cPickle,types,os class ListShelf: def __init__(self,filename): """ Open file for updating if it exists, otherwise create it. """ if not os.access(filename,os.F_OK): os.open(filename,os.O_CREAT) self.file=open(filename,'r+') def get(self): return self._load() def _dump(self,_list): """ Seek to the beginning of file and cPickle the list to it. """ self.file.seek(0) cPickle.dump(_list,self.file) def _load(self): """ Seek to the beginning of file and un-cPickle the list from it. If the file is empty, return an empty list. """ self.file.seek(0) try: return cPickle.load(self.file) except EOFError: return [] def __iadd__(self,other): "ie. list+=other" _list=self._load() _list+=other self._dump(_list) def __imul__(self,other): "ie. list*=other" _list=self._load() _list*=other self._dump(_list) From kalle@gnupung.net Wed Jun 6 16:14:14 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Wed, 6 Jun 2001 17:14:14 +0200 Subject: [Tutor] List mimicing In-Reply-To: ; from toodles@yifan.net on Wed, Jun 06, 2001 at 10:18:14PM +0800 References: Message-ID: <20010606171414.A11739@father> Sez Andrew Wilkins: > Hi folks, > > I'm creating a class somewhat like shelve that stores a list as a file, and > provides a very list-like interface to it. I'm having troubles with __iadd__ > and __imul__ however. [snip] You want to take a look at the class UserList in the module UserList in the standard library. > -------- code ---------- > > import cPickle,types,os > > class ListShelf: [snip] > def __iadd__(self,other): > "ie. list+=other" > _list=self._load() > _list+=other > self._dump(_list) return self > def __imul__(self,other): > "ie. list*=other" > _list=self._load() > _list*=other > self._dump(_list) return self Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From tescoil@irtc.net Wed Jun 6 17:04:45 2001 From: tescoil@irtc.net (Tesla Coil) Date: Wed, 06 Jun 2001 11:04:45 -0500 Subject: [Tutor] Converting problem sets from other languages into Python? References: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> Message-ID: <3B1E549D.95898EA4@irtc.net> On 6 June 2001, Rob Andrews wrote: > While we're kinda on the subject, I'll go ahead > and leak an up-coming feature for Useless. (First > I need to finish the program that will automatically > generate the HTML pages, but I'm mostly there.) > > Once it's begun, for each script someone contributes > to Useless, the contributor will be able to add an > icon to a script by someone else, indicating one of > several things ("I actually used this", "I learned > something from this", "This is indeed Useless", etc.). Should have voting review skill and style rather than utility, e.g, Elegant, Genius from Mars, Runs with Square Wheels, Just When You Thought Obfuscated Python Didn't Exist, etc. This sort of commentary can be made regardless of what a program proposes to do. And, however one rates the utility of working code to solve the Knight's Tour puzzle (I, for one, am not too sure), the question is probably of less consequence to the programmer's next effort than what could be said of how well it was implemented. From GBunting864@Worldsavings.com Wed Jun 6 17:09:55 2001 From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x)) Date: Wed, 6 Jun 2001 11:09:55 -0500 Subject: [Tutor] python and Microsoft proxy server Message-ID: <97E9FA3149D0D311BE5800008349BB27016692F8@ok1ems1.worldsavings.com> Hi, I am trying to learn Python and I would like to try out the urllib module. The problem is everything here goes out through Microsoft's Proxy server which authenticates with NTLM. Is there any way to allow Python to authenticate with the proxy server so I can get to the Internet with Python? Thanks, Glen ***************************************************************************** If you are not the intended recipient of this e-mail, please notify the sender immediately. The contents of this e-mail do not amend any existing disclosures or agreements unless expressly stated. ***************************************************************************** From britt_green@hotmail.com Wed Jun 6 17:29:05 2001 From: britt_green@hotmail.com (Britt Green) Date: Wed, 06 Jun 2001 09:29:05 -0700 Subject: [Tutor] Paths under WinNT? Message-ID: Hey, I was wondering if someone could help me set up my path under Windows NT. Is there a way to point it to the Python2.1 folder, so it'll see everything that lives underneath that? Currently, if I have a class in a folder within Python 2.1 and try to import it, Python can't find it. I'm in the position of not knowing enough about WinNT to change my path so any advice is welcome. Britt -- It is pitch black. You are likely to be eaten by a grue. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From GBunting864@Worldsavings.com Wed Jun 6 17:41:30 2001 From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x)) Date: Wed, 6 Jun 2001 11:41:30 -0500 Subject: [Tutor] Paths under WinNT? Message-ID: <97E9FA3149D0D311BE5800008349BB27016693B5@ok1ems1.worldsavings.com> Britt, To set the path, all you need to do is right click on My Computer and choose properties. Then click on the environment tab, highlight path under the system variables, then add the path you want entered in the value section. Glen -----Original Message----- From: Britt Green [mailto:britt_green@hotmail.com] Sent: Wednesday, June 06, 2001 9:29 AM To: tutor@python.org Subject: [Tutor] Paths under WinNT? Hey, I was wondering if someone could help me set up my path under Windows NT. Is there a way to point it to the Python2.1 folder, so it'll see everything that lives underneath that? Currently, if I have a class in a folder within Python 2.1 and try to import it, Python can't find it. I'm in the position of not knowing enough about WinNT to change my path so any advice is welcome. Britt -- It is pitch black. You are likely to be eaten by a grue. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ***************************************************************************** If you are not the intended recipient of this e-mail, please notify the sender immediately. The contents of this e-mail do not amend any existing disclosures or agreements unless expressly stated. ***************************************************************************** From dsh8290@rit.edu Wed Jun 6 18:03:45 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 6 Jun 2001 13:03:45 -0400 Subject: [Tutor] Access to Windows Timers / Idle "states"?? In-Reply-To: <007d01c0ee8a$018b5560$0124a8c0@uno>; from python.tutorial@jarava.org on Wed, Jun 06, 2001 at 03:10:05PM +0200 References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605222453.B14318@harmony.cs.rit.edu> <007d01c0ee8a$018b5560$0124a8c0@uno> Message-ID: <20010606130345.E12381@connecticut.cs.rit.edu> On Wed, Jun 06, 2001 at 03:10:05PM +0200, Javier JJ wrote: | > | So, I'd like to be able to "sense" when the OS hasn't been getting | > | any imput (keys / mouse) for a set period of time and, if that | > | happens, it'll just kill the offending process.... | > | | > | Am I making any sense at all? | > | > Yes -- you want to prevent your OS from locking up (IOW failing to | | Welll. it's not really (at least it doesn't seem) like it's really frozen | solid.. only that the screen is and not all inputs are handled.. but the | network and services go on (eprompter keeps checking the mail, etc). I had | wondered about another solution: building a xmlrpc or similar server that | would let me "kill" the offending process when triggered from another | machine. Buy having the two computers on is something I'd rather avoid :-)) I think telnetd or sshd might be distributed with cygwin. Any real networked/multiuser OS allows for remote access anyways... (where'd the 'su' equivalent disappear to... I shouldn't be logged in as administrator for day-to-day work, yet I shouldn't have to log out just to install a new toy... oh, yeah, this is windows ) | > meet its requirements). The solution is much simpler : use Debian! | | Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found | HlafLife - Front Line Force for Linux .... and besides, I don't think I | could switch to linux and be 100% productive as of yet .... | | > Sorry, not much help with the code, but I don't try and fix windows by | > writing my own watchdog timer and am not sure how you would do | > that reliably. | | Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses | to signal "no activity" (ie, the same ones that the OS uses to know when to | fire the screensaver), that'd be fairly simple to do. .. Does the screensaver kick in if you leave it idle long enough? If so then you should write a screensaver :-). The screensaver won't be an ordinary, flash-some-colors-on-the-screen sort of thing but it would kill the offending process if it exists then exec the "real" screensaver for those situations where you really want a screen saver. I think this sort of thing would be relatively easy if MS allowed for custom window managers because the window manager gets all input (keyboard, mouse, etc) events and figures out whether to keep them (and deal with it) or pass it on to the app. I suppose, if this were X, you could create a layer that would see all events from the X server and determine whether to kill the bad app or not and pass them on to the real WM. Anyways, the telnetd or screensaver idea are the most realistic/doable ideas. -D From rob@jam.rr.com Wed Jun 6 18:28:00 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 6 Jun 2001 12:28:00 -0500 Subject: [Tutor] Converting problem sets from other languages into Python? References: <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> <3B1E549D.95898EA4@irtc.net> Message-ID: <004701c0eeae$092df1a0$de00a8c0@planhouse5> ----- Original Message ----- From: "Tesla Coil" To: "Rob Andrews" Cc: Sent: Wednesday, June 06, 2001 11:04 AM Subject: Re: [Tutor] Converting problem sets from other languages into Python? > > Should have voting review skill and style rather > than utility, e.g, Elegant, Genius from Mars, > Runs with Square Wheels, Just When You Thought > Obfuscated Python Didn't Exist, etc. This sort > of commentary can be made regardless of what a > program proposes to do. And, however one rates > the utility of working code to solve the Knight's > Tour puzzle (I, for one, am not too sure), the > question is probably of less consequence to the > programmer's next effort than what could be said > of how well it was implemented. > Actually, these are also options. I have quite a few in mind, and each will have its own distinct graphic. I don't understand the *Runs with Square Wheels* one, though. hehe Rob Useless Python It's not just for breakfast anymore! http://www.lowerstandard.com/python/index.html From kstoner@netins.net Wed Jun 6 18:40:43 2001 From: kstoner@netins.net (Katharine Stoner) Date: Wed, 6 Jun 2001 12:40:43 -0500 Subject: [Tutor] beginners out there Message-ID: <001801c0eeaf$cff1ed40$8352b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C0EE85.E67BADA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This is a shout out to all the beginners who need some help finding = explainations on they're own. Everything you need get to that is online documentation is at python's = homepage. Some of it just takes a while to get to. You have to dig a = bit to find the good stuff. There are some lesson plans that help on = explaining things http://www.livewires.org.uk/python/. This explains = some of the lingo that goes with programing and how some of the = fundamentals work. Its all in html format or Adobe Acrobat reader = format ready to be downloaded. Alan Guald's book is probably the best easy, down to earth beginners = book I've found. The best way to approach this that I've found is to = watch the tutor emails, get a book, find some tutorials, get a project, = and start playing around with code. Any beginner question would be fine = here. We have the tutor emails to help one another learn better. I'm = about 8 months into my Python education and it takes time to learn how = to program with the basics. This is just one beginner to another. -Cameron ------=_NextPart_000_0015_01C0EE85.E67BADA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
This is a shout out to all the = beginners who need=20 some help finding explainations on they're own.
 
Everything you need get to that is = online=20 documentation is at python's homepage.  Some of it just takes a = while to=20 get to. You have to dig a bit to find the good stuff.  There = are some=20 lesson plans that help on explaining things http://www.livewires.org.uk/= python/. =20 This explains some of the lingo that goes with programing and how some = of the=20 fundamentals work.  Its all in html format or Adobe Acrobat reader = format=20 ready to be downloaded.
Alan Guald's book is probably the best = easy, down=20 to earth beginners book I've found.  The best way to approach this = that=20 I've found is to watch the tutor emails, get a book, find some = tutorials, get a=20 project, and start playing around with code.  Any beginner question = would=20 be fine here.  We have the tutor emails to help one another learn=20 better.  I'm about 8 months into my Python education and it takes = time to=20 learn how to program with the basics.
 
This is just one beginner to = another.
 
-Cameron
------=_NextPart_000_0015_01C0EE85.E67BADA0-- From pobrien@orbtech.com Wed Jun 6 18:00:05 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 12:00:05 -0500 Subject: [Tutor] Best way to strip string string padded with nulls Message-ID: I'm working with DDE to get data out of Goldmine. The data returned from Goldmine is padded with nulls (and other random data, see example below). I need to strip the resulting string down to just the relevant data. I have some example code here that works, but I'm looking for suggestions for a simpler or more elegant approach. Thanks. Here is a snippet from an interactive session so you can see what I have described above: >>> c = conversation.Request("Contact1->Company") >>> c 'GoldMine Software Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff' >>> i = c.index('\x00') >>> i 29 >>> a = c[:i] >>> a 'GoldMine Software Corporation' Of course, this could also be collapsed to the following: c = c[:c.index('\00')] But considering the fact that I'll have to do this to every string that gets returned via DDE requests, I'm hoping there is a better way. Thanks for the help. --- Patrick K. O'Brien Orbtech "I am, therefore I think." From ak@silmarill.org Wed Jun 6 18:48:11 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Wed, 06 Jun 2001 13:48:11 -0400 Subject: [Tutor] Access to Windows Timers / Idle "states"?? In-Reply-To: <"from dsh8290"@rit.edu> References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605222453.B14318@harmony.cs.rit.edu> <007d01c0ee8a$018b5560$0124a8c0@uno> <20010606130345.E12381@connecticut.cs.rit.edu> Message-ID: <20010606134811.A27269@sill.silmarill.org> On Wed, Jun 06, 2001 at 01:03:45PM -0400, D-Man wrote: > On Wed, Jun 06, 2001 at 03:10:05PM +0200, Javier JJ wrote: > | > | So, I'd like to be able to "sense" when the OS hasn't been getting > | > | any imput (keys / mouse) for a set period of time and, if that > | > | happens, it'll just kill the offending process.... > | > | > | > | Am I making any sense at all? > | > > | > Yes -- you want to prevent your OS from locking up (IOW failing to > | > | Welll. it's not really (at least it doesn't seem) like it's really frozen > | solid.. only that the screen is and not all inputs are handled.. but the > | network and services go on (eprompter keeps checking the mail, etc). I had > | wondered about another solution: building a xmlrpc or similar server that > | would let me "kill" the offending process when triggered from another > | machine. Buy having the two computers on is something I'd rather avoid :-)) > > I think telnetd or sshd might be distributed with cygwin. Any real > networked/multiuser OS allows for remote access anyways... > > (where'd the 'su' equivalent disappear to... I shouldn't be logged in as > administrator for day-to-day work, yet I shouldn't have to log out > just to install a new toy... oh, yeah, this is windows ) > > | > meet its requirements). The solution is much simpler : use Debian! > | > | Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found > > > > | HlafLife - Front Line Force for Linux .... and besides, I don't think I > | could switch to linux and be 100% productive as of yet .... > | > | > Sorry, not much help with the code, but I don't try and fix windows by > | > writing my own watchdog timer and am not sure how you would do > | > that reliably. > | > | Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses > | to signal "no activity" (ie, the same ones that the OS uses to know when to > | fire the screensaver), that'd be fairly simple to do. .. > > Does the screensaver kick in if you leave it idle long enough? If so > then you should write a screensaver :-). The screensaver won't be an > ordinary, flash-some-colors-on-the-screen sort of thing but it would > kill the offending process if it exists then exec the "real" > screensaver for those situations where you really want a screen saver. > > I think this sort of thing would be relatively easy if MS allowed for > custom window managers because the window manager gets all input > (keyboard, mouse, etc) events and figures out whether to keep them > (and deal with it) or pass it on to the app. I suppose, if this were > X, you could create a layer that would see all events from the X > server and determine whether to kill the bad app or not and pass them > on to the real WM. Well if this was X, you could just ctrl-alt-F2 to second console and kill the offending process.. :-) > > Anyways, the telnetd or screensaver idea are the most realistic/doable > ideas. > > -D > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From scarblac@pino.selwerd.nl Wed Jun 6 18:56:37 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 6 Jun 2001 19:56:37 +0200 Subject: [Tutor] Best way to strip string string padded with nulls In-Reply-To: ; from pobrien@orbtech.com on Wed, Jun 06, 2001 at 12:00:05PM -0500 References: Message-ID: <20010606195636.A19968@pino.selwerd.nl> On 0, "Patrick K. O'Brien" wrote: > I'm working with DDE to get data out of Goldmine. The data returned from > Goldmine is padded with nulls (and other random data, see example below). I > need to strip the resulting string down to just the relevant data. I have > some example code here that works, but I'm looking for suggestions for a > simpler or more elegant approach. Thanks. > > Here is a snippet from an interactive session so you can see what I have > described above: > > >>> c = conversation.Request("Contact1->Company") > >>> c > 'GoldMine Software > Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ > x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff' > >>> i = c.index('\x00') > >>> i > 29 > >>> a = c[:i] > >>> a > 'GoldMine Software Corporation' > > Of course, this could also be collapsed to the following: > > c = c[:c.index('\00')] > > But considering the fact that I'll have to do this to every string that gets > returned via DDE requests, I'm hoping there is a better way. Thanks for the > help. c = c.replace('\00', '') -- Remco Gerlich From scarblac@pino.selwerd.nl Wed Jun 6 19:01:12 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 6 Jun 2001 20:01:12 +0200 Subject: [Tutor] Best way to strip string string padded with nulls In-Reply-To: ; from pobrien@orbtech.com on Wed, Jun 06, 2001 at 12:00:05PM -0500 References: Message-ID: <20010606200112.A19981@pino.selwerd.nl> On 0, "Patrick K. O'Brien" wrote: > I'm working with DDE to get data out of Goldmine. The data returned from > Goldmine is padded with nulls (and other random data, see example below). I > need to strip the resulting string down to just the relevant data. I have > some example code here that works, but I'm looking for suggestions for a > simpler or more elegant approach. Thanks. > > Here is a snippet from an interactive session so you can see what I have > described above: > > >>> c = conversation.Request("Contact1->Company") > >>> c > 'GoldMine Software > Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ > x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff' > >>> i = c.index('\x00') > >>> i > 29 > >>> a = c[:i] > >>> a > 'GoldMine Software Corporation' > > Of course, this could also be collapsed to the following: > > c = c[:c.index('\00')] > > But considering the fact that I'll have to do this to every string that gets > returned via DDE requests, I'm hoping there is a better way. Thanks for the > help. Hmm, seems I solved the wrong problem *again*. You want to delete the stuff after the nulls as well. I think that last line of code you have there is the best option. -- Remco Gerlich From pobrien@orbtech.com Wed Jun 6 19:17:15 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 13:17:15 -0500 Subject: [Tutor] Best way to strip string string padded with nulls In-Reply-To: <20010606200112.A19981@pino.selwerd.nl> Message-ID: Yeah. Your suggestion would work if the padding were all nulls, but Goldmine manages to send back some random junk as well. So I do need to just cut it short at the very first null. Thanks anyway. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Remco Gerlich Sent: Wednesday, June 06, 2001 1:01 PM To: tutor@python.org Subject: Re: [Tutor] Best way to strip string string padded with nulls Hmm, seems I solved the wrong problem *again*. You want to delete the stuff after the nulls as well. I think that last line of code you have there is the best option. -- Remco Gerlich _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From kojo@hal-pc.org Wed Jun 6 19:45:06 2001 From: kojo@hal-pc.org (Kojo Idrissa) Date: Wed, 06 Jun 2001 13:45:06 -0500 Subject: [Tutor] beginners out there In-Reply-To: <001801c0eeaf$cff1ed40$8352b1cf@oemcomputer> Message-ID: <5.0.2.1.0.20010606131223.00ae5dd0@Pop3.norton.antivirus> --=====================_94567841==_.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed As is often my way, I will now jump on the bandwagon started by someone else. In this case, Cameron. As a little motivation for the beginners out there ( and I've been beginning for a long time now...), here's a snippet from a "Python 101" article on Devshed.: In the consciously-elitist world of software engineering, a developer with a few years of Python under his belt gets the best cubicle, the prettiest girl and the respect of his neighbours; people move out of the way when he strides down the hall, and colleagues turn to him for creative and elegant solutions to the problems they encounter. Walk into a job interview and mention Python when reciting your qualifications; you'll immediately see a glint of recognition in the interviewer's eyes, an awareness that, in the hierarchy of software developers, you're one of the top guns Of course, that's a joke, but it's the lead off of a series of "Python 101" articles that they're doing. Here's the URL: Also, some of you new to programming may want to become "serious" about it. I'm sure that means something different to everyon...in my case I'm starting on a Comp. Sci. degree and plan to do this sort of thing for the rest of my life. Anyway, I'm currently reading: "How to Think Like a Computer Scientist." It uses Python as it's language of instruction, and can be downloaded all at once as a .tgz file (Winzip can open these). I found that helpfull, so I can read while not online. "How to Design Programs: An Introduction to Computing and Programming" This one uses Scheme as it's language, but the snippet below explains why I'd recommend it to beginners: This book is the first book on programming as the core subject of a liberal arts education. Its main focus is the design process that leads from problem statements to well-organized solutions; it de-emphasizes the study of programming language details, algorithmic minutiae, and specific application domains. I also recall a number of posts to this list asking how to go about designing a larger program. This would seem to address that concern. In addition, I think we all, no matter what we do in life, have problems we have to deal with that could use well-organized solutions. This link "book" would probably be better after you've spent a little time with Python, but you can learn so much Python so quickly, you'll be suprised. Also, if you already have a program idea in mind, working on the design can help you focus what parts of Python you should study. ("Ok, so how do I generate a random number for my RPG dice rolls module?") Just my US$.02 (Ok, it's more like a nickel...I'm verbose). I'd also second most of what Cameron said. He tends to post very interesting questions that make it obvious that he's learning more about the language as time goes on. This list is also an excellent resource. People respond quickly and with good information [I think, at times, I may be one of the exceptions, so I try to stay quiet...:-)], and if they don't know what you're asking, they don't YELL at you, they ask for more details. I Love You Guys!! Ok, that's enough. Now I must eat, read and write. At 12:40 PM 6/6/2001 -0500, Katharine Stoner wrote: >This is a shout out to all the beginners who need some help finding >explainations on they're own. > >Everything you need get to that is online documentation is at python's >homepage. Some of it just takes a while to get to. You have to dig a bit >to find the good stuff. There are some lesson plans that help on >explaining things >http://www.livewires.org.uk/python/. >This explains some of the lingo that goes with programing and how some of >the fundamentals work. Its all in html format or Adobe Acrobat reader >format ready to be downloaded. >Alan Guald's book is probably the best easy, down to earth beginners book >I've found. The best way to approach this that I've found is to watch the >tutor emails, get a book, find some tutorials, get a project, and start >playing around with code. Any beginner question would be fine here. We >have the tutor emails to help one another learn better. I'm about 8 >months into my Python education and it takes time to learn how to program >with the basics. > >This is just one beginner to another. > >-Cameron **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo/ **************************** --=====================_94567841==_.ALT Content-Type: text/html; charset="us-ascii" As is often my way, I will now jump on the bandwagon started by someone else.  In this case, Cameron.

As a little motivation for the beginners out there ( and I've been beginning for a long time now...), here's a snippet from a "Python 101" article on Devshed.:
In the consciously-elitist world of software engineering, a developer with a few years of Python under his belt gets the best cubicle, the prettiest girl and the respect of his neighbours; people move out of the way when he strides down the hall, and colleagues turn to him for creative and elegant solutions to the problems they encounter. Walk into a job interview and mention Python when reciting your qualifications; you'll immediately see a glint of recognition in the interviewer's eyes, an awareness that, in the hierarchy of software developers, you're one of the top guns



Of course, that's a joke, but it's the lead off of a series of "Python 101" articles that they're doing.  Here's the URL:
<http://www.devshed.com/Server_Side/Python/Python101_1/page1.html>

Also, some  of you new to programming may want to become "serious" about it.  I'm sure that means something different to everyon...in my case I'm starting on a Comp. Sci. degree and plan to do this sort of thing for the rest of my life.  Anyway, I'm currently reading:

"How to Think Like a Computer Scientist."
<http://www.ibiblio.org/obp/thinkCSpy/>
It uses Python as it's language of instruction, and can be downloaded all at once as a .tgz file (Winzip can open these).  I found that helpfull, so I can read while not online.


"How to Design Programs: An Introduction to Computing and Programming"
<http://www.htdp.org/2001-01-18/Book/ >
This one uses Scheme as it's language, but the snippet below explains why I'd recommend it to beginners:
This book is the first book on programming as the core subject of a liberal arts education. Its main focus is the design process that leads from problem statements to well-organized solutions; it de-emphasizes the study of programming language details, algorithmic minutiae, and specific application domains.

I also recall a number of posts to this list asking how to go about designing a larger program.  This would seem to address that concern.  In addition, I think we all, no matter what we do in life, have problems we have to deal with that could use well-organized solutions.  This link "book" would probably be better after you've spent a little time with Python, but you can learn so much Python so quickly, you'll be suprised.  Also, if you already have a program idea in mind, working on the design can help you focus what parts of Python you should study. ("Ok, so how do I generate a random number for my RPG dice rolls module?")

Just my US$.02 (Ok, it's more like a nickel...I'm verbose).  I'd also second most of what Cameron said.  He tends to post very interesting questions that make it obvious that he's learning more about the language as time goes on. 

This list is also an excellent resource.  People respond quickly and with good information [I think, at times, I may be one of the exceptions, so I try to stay quiet...:-)], and if they don't know what you're asking, they don't YELL at you, they ask for more details.  I Love You Guys!!

Ok, that's enough.  Now I must eat, read and write.


At 12:40 PM 6/6/2001 -0500, Katharine Stoner wrote:
This is a shout out to all the beginners who need some help finding explainations on they're own.
 
Everything you need get to that is online documentation is at python's homepage.  Some of it just takes a while to get to. You have to dig a bit to find the good stuff.  There are some lesson plans that help on explaining things http://www.livewires.org.uk/python/.  This explains some of the lingo that goes with programing and how some of the fundamentals work.  Its all in html format or Adobe Acrobat reader format ready to be downloaded.
Alan Guald's book is probably the best easy, down to earth beginners book I've found.  The best way to approach this that I've found is to watch the tutor emails, get a book, find some tutorials, get a project, and start playing around with code.  Any beginner question would be fine here.  We have the tutor emails to help one another learn better.  I'm about 8 months into my Python education and it takes time to learn how to program with the basics.
 
This is just one beginner to another.
 
-Cameron

****************************
Kojo Idrissa
 
kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
**************************** --=====================_94567841==_.ALT-- From pobrien@orbtech.com Wed Jun 6 19:45:19 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 13:45:19 -0500 Subject: [Tutor] Best way to strip string string padded with nulls In-Reply-To: Message-ID: Here's one problem with my solution. null = '\x00' c = conversation.Request("Contact1->Company") c = c[:c.index(null)] If there is no null in c, index returns a ValueError that would have to be dealt with. Worse is if I used c.find(null) since find would return -1 which would eat the last character of c. Looks like I still need to work on this. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Wednesday, June 06, 2001 12:00 PM To: Python Tutor Subject: [Tutor] Best way to strip string string padded with nulls I'm working with DDE to get data out of Goldmine. The data returned from Goldmine is padded with nulls (and other random data, see example below). I need to strip the resulting string down to just the relevant data. I have some example code here that works, but I'm looking for suggestions for a simpler or more elegant approach. Thanks. Here is a snippet from an interactive session so you can see what I have described above: >>> c = conversation.Request("Contact1->Company") >>> c 'GoldMine Software Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff' >>> i = c.index('\x00') >>> i 29 >>> a = c[:i] >>> a 'GoldMine Software Corporation' Of course, this could also be collapsed to the following: c = c[:c.index('\00')] But considering the fact that I'll have to do this to every string that gets returned via DDE requests, I'm hoping there is a better way. Thanks for the help. --- Patrick K. O'Brien Orbtech "I am, therefore I think." _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From kauphlyn@speakeasy.org Wed Jun 6 20:14:45 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Wed, 6 Jun 2001 12:14:45 -0700 (PDT) Subject: [Tutor] parsing a blank-separated string into a list In-Reply-To: Message-ID: Hey Eugene, Long time since Planeria, eh? try >>jmevalue = ' 10 11 C 9.13 ect ' >>jmelist = jmevalue.split(' ') >>jmelist ['10', '11', 'C', '9.13', etc] On Wed, 6 Jun 2001, Eugene Leitl wrote: > > Assuming, I have a string like this (produced by the JME applet, > encoding a molecule I entered): > > 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C > 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 > 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1 > > And want to turn it into a list like this: > > [10, 11, C, 9.13 ... ] > > How do I do it? > > jmelist = map(None, jmevalue) produces > > [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms. > > Is there an idiom for that? (I mean, it's of course possible to do it by > hand, but it's not Python Zen). > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From kauphlyn@speakeasy.org Wed Jun 6 20:30:41 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Wed, 6 Jun 2001 12:30:41 -0700 (PDT) Subject: [Tutor] parsing a blank-separated string into a list In-Reply-To: Message-ID: What I wrote below works for Python 2.0 , and I dont know when it was implemented, but it definitely doesnt work on my Linux box, which is running python 1.5.2. For that, I did the following: import re jmelist = re.split(' ', jmevalue) Hope that helps, and sorry for any confusions for people with older versions ;-) On Wed, 6 Jun 2001, Daniel Coughlin wrote: > Hey Eugene, > > Long time since Planeria, eh? > > try > >>jmevalue = ' 10 11 C 9.13 ect ' > >>jmelist = jmevalue.split(' ') > >>jmelist > ['10', '11', 'C', '9.13', etc] > > > > On Wed, 6 Jun 2001, Eugene Leitl wrote: > > > > > Assuming, I have a string like this (produced by the JME applet, > > encoding a molecule I entered): > > > > 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C > > 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3 > > 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1 > > > > And want to turn it into a list like this: > > > > [10, 11, C, 9.13 ... ] > > > > How do I do it? > > > > jmelist = map(None, jmevalue) produces > > > > [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms. > > > > Is there an idiom for that? (I mean, it's of course possible to do it by > > hand, but it's not Python Zen). > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > From pobrien@orbtech.com Wed Jun 6 20:32:16 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 14:32:16 -0500 Subject: [Tutor] Best way to strip string string padded with nulls In-Reply-To: Message-ID: This is what I've come up with so far. I'm still open to suggestions. def nullstrip(s): """Return a string truncated at the first null character.""" try: s = s[:s.index('\x00')] except ValueError: # No nulls were found, which is okay. pass return s --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: Patrick K. O'Brien [mailto:pobrien@orbtech.com] Sent: Wednesday, June 06, 2001 1:45 PM To: Python Tutor Subject: RE: [Tutor] Best way to strip string string padded with nulls Here's one problem with my solution. null = '\x00' c = conversation.Request("Contact1->Company") c = c[:c.index(null)] If there is no null in c, index returns a ValueError that would have to be dealt with. Worse is if I used c.find(null) since find would return -1 which would eat the last character of c. Looks like I still need to work on this. --- Patrick K. O'Brien Orbtech "I am, therefore I think." From pobrien@orbtech.com Wed Jun 6 22:38:53 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 16:38:53 -0500 Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls In-Reply-To: Message-ID: The function I came up with is obviously useful in a variety of contexts. So it probably ought to go into some kind of general utility file. What kind of standards do the rest of you follow when you find yourself with generic bits of code like this? Do you have a particular file or set of files in which to put these general functions? --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Wednesday, June 06, 2001 2:32 PM To: Python Tutor Subject: RE: [Tutor] Best way to strip string string padded with nulls This is what I've come up with so far. I'm still open to suggestions. def nullstrip(s): """Return a string truncated at the first null character.""" try: s = s[:s.index('\x00')] except ValueError: # No nulls were found, which is okay. pass return s --- Patrick K. O'Brien Orbtech "I am, therefore I think." From ak@silmarill.org Wed Jun 6 23:02:18 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Wed, 06 Jun 2001 18:02:18 -0400 Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls In-Reply-To: <"from pobrien"@orbtech.com> References: Message-ID: <20010606180218.A28726@sill.silmarill.org> On Wed, Jun 06, 2001 at 04:38:53PM -0500, Patrick K. O'Brien wrote: > The function I came up with is obviously useful in a variety of contexts. So > it probably ought to go into some kind of general utility file. What kind of > standards do the rest of you follow when you find yourself with generic bits > of code like this? Do you have a particular file or set of files in which to > put these general functions? > > --- > Patrick K. O'Brien > Orbtech > "I am, therefore I think." > > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Patrick K. O'Brien > Sent: Wednesday, June 06, 2001 2:32 PM > To: Python Tutor > Subject: RE: [Tutor] Best way to strip string string padded with nulls > > This is what I've come up with so far. I'm still open to suggestions. > > def nullstrip(s): > """Return a string truncated at the first null character.""" > try: > s = s[:s.index('\x00')] > except ValueError: # No nulls were found, which is okay. > pass > return s ActiveState python cookbook, I don't have url on hand so google for it. > > --- > Patrick K. O'Brien > Orbtech > "I am, therefore I think." > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Shine on you crazy diamond - Roger From pobrien@orbtech.com Wed Jun 6 23:24:10 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 6 Jun 2001 17:24:10 -0500 Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls In-Reply-To: <20010606180218.A28726@sill.silmarill.org> Message-ID: I think my question might not have been clear enough. I was wondering where to put these functions on my local machine. For example, should I create a file like utility.py and import that file into my other programs so I can make use of these little utility functions, like my stripnull()? Does that make sense? What do the rest of you do? BTW, the reference you gave is an excellent resource that I've been checking out whenever I need to do something new. The url is http://aspn.activestate.com/ASPN/Python/Cookbook/ and there are lots of interesting code examples. I may just take your suggestion and post my little function there. Thanks. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of sill@optonline.net Sent: Wednesday, June 06, 2001 5:02 PM To: Python Tutor Subject: Re: [Tutor] Utility functions - was: Best way to strip string string padded with nulls ActiveState python cookbook, I don't have url on hand so google for it. -- Shine on you crazy diamond - Roger _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From rik_klaver@hotmail.com Wed Jun 6 23:47:08 2001 From: rik_klaver@hotmail.com (Rik Klaver) Date: Wed, 06 Jun 2001 22:47:08 Subject: [Tutor] importing modules Message-ID: I have downloaded some modules (or packages), which I've already put under the 'Python21' folder in Win98. My problem is: Python lets me import some, such as dynwin, pmw and pingo, but not the Mmtk20, Numeric and Htmlgen. For some modules Python raises a SystemError. Is the fact that Python does not recognize these modules due to their DOS-names or to Python immediately recognizing, whenever a module is imported, a (say) __init__-file? I have no idea and I would very much like to use these modules (especially the Mtmk).. thanks in advance for any comments Rik Klaver _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From toodles@yifan.net Thu Jun 7 02:14:44 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Thu, 7 Jun 2001 09:14:44 +0800 Subject: [Tutor] List mimicing In-Reply-To: <20010606171414.A11739@father> Message-ID: > Sez Andrew Wilkins: > > Hi folks, > > > > I'm creating a class somewhat like shelve that stores a list as > a file, and > > provides a very list-like interface to it. I'm having troubles > with __iadd__ > > and __imul__ however. > [snip] > > You want to take a look at the class UserList in the module > UserList in the > standard library. Okay, I can do that, but I'll still be overriding everything anyway won't I? In which case __imul__ and __iadd__ will still act the same? I'll play around with it anyway, and see if I'm wrong =) > > > -------- code ---------- > > > > import cPickle,types,os > > > > class ListShelf: > [snip] > > def __iadd__(self,other): > > "ie. list+=other" > > _list=self._load() > > _list+=other > > self._dump(_list) > > return self > > > def __imul__(self,other): > > "ie. list*=other" > > _list=self._load() > > _list*=other > > self._dump(_list) > > return self > > Peace, > Kalle > -- > Email: kalle@gnupung.net | You can tune a filesystem, but you > Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) > PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD > [ Not signed due to lossage. Blame Microsoft Outlook Express. ] > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From toodles@yifan.net Thu Jun 7 04:12:30 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Thu, 7 Jun 2001 11:12:30 +0800 Subject: [Tutor] List mimicing In-Reply-To: <20010606171414.A11739@father> Message-ID: Okay I've fixed it now. Thanks Kalle, I looked through the source of UserList and found the prob :) Also I've subclassed it now, and changed the way it works so it cuts a lot of method definitions out...I'll post this to Rob for Useless later if anyone is even remotely interested. heh Andrew Wilkins > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Kalle Svensson > Sent: Wednesday, 6 June 2001 11:14 PM > To: tutor@python.org > Subject: Re: [Tutor] List mimicing > > > Sez Andrew Wilkins: > > Hi folks, > > > > I'm creating a class somewhat like shelve that stores a list as > a file, and > > provides a very list-like interface to it. I'm having troubles > with __iadd__ > > and __imul__ however. > [snip] > > You want to take a look at the class UserList in the module > UserList in the > standard library. > > > -------- code ---------- > > > > import cPickle,types,os > > > > class ListShelf: > [snip] > > def __iadd__(self,other): > > "ie. list+=other" > > _list=self._load() > > _list+=other > > self._dump(_list) > > return self > > > def __imul__(self,other): > > "ie. list*=other" > > _list=self._load() > > _list*=other > > self._dump(_list) > > return self > > Peace, > Kalle > -- > Email: kalle@gnupung.net | You can tune a filesystem, but you > Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) > PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD > [ Not signed due to lossage. Blame Microsoft Outlook Express. ] > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From kromag@nsacom.net Thu Jun 7 17:37:29 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Thu, 7 Jun 2001 09:37:29 -0700 (PDT) Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding Message-ID: <200106071637.f57GbTg11731@pop.nsacom.net> Several weeks ago I posted a question about parsing data from a serial port. The data from the serial port uses a binary 3 to signal that it is through transmitting. Someone mentioned that the ExpectPy module might be a good candidate for parsing this data. Does anyone have a HOWTO for ExpectPy? Thanks! From rickyp1@frontiernet.net Thu Jun 7 17:05:08 2001 From: rickyp1@frontiernet.net (Ricky Parks) Date: Thu, 7 Jun 2001 11:05:08 -0500 Subject: [Tutor] Finaly Message-ID: <006a01c0ef6c$000e0880$6601a8c0@Parks> This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C0EF41.B6B4F880 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I can not find where to unsubscibe. Could some one help me! I have given = up python! ------=_NextPart_000_000B_01C0EF41.B6B4F880 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I can not find where to unsubscibe. = Could some one=20 help me! I have given up python!
------=_NextPart_000_000B_01C0EF41.B6B4F880-- From scarblac@pino.selwerd.nl Thu Jun 7 17:21:43 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 7 Jun 2001 18:21:43 +0200 Subject: [Tutor] Finaly In-Reply-To: <006a01c0ef6c$000e0880$6601a8c0@Parks>; from rickyp1@frontiernet.net on Thu, Jun 07, 2001 at 11:05:08AM -0500 References: <006a01c0ef6c$000e0880$6601a8c0@Parks> Message-ID: <20010607182143.A21324@pino.selwerd.nl> On 0, Ricky Parks wrote: > I can not find where to unsubscibe. Could some one help me! I have given up python! Sorry to hear you've given up Python... Anyway, you can unsubscribe at the mailman page for this list, http://mail.python.org/mailman/listinfo/tutor Enter your email address in the 'Edit Options' box at the bottom and you'll go to a page where you can unsubscribe. -- Remco Gerlich From abbn@v-share.com Thu Jun 7 17:48:33 2001 From: abbn@v-share.com (Vassilis Vassiliou) Date: Thu, 7 Jun 2001 19:48:33 +0300 Subject: [Tutor] Shareware Software Registration Services Message-ID: <200106071648.f57GmXS13803@v-share.com> Dear Software Vendor, Our company Visage Services Inc. offers valuable shareware software registration services to many developers for the past 4 years. Being ourselves shareware software developers we created in 1998 a state of the art service administration system which proved very reliable and prosperous, due to its highly adaptable flexibility. Taking into consideration our very attractive fee schedule this could be a major opportunity to enhance your profits at a minimum cost. Please visit our site at http://www.v-share.com for a detailed description of these services and our fee schedule. Should you need assistance, feel free to contact me anytime. Thank you for your time reading my mail. Sincerely, Vassilis Vassiliou Sales Manager VISAGE SERVICES INC. abbn@v-share.com From curtis.larsen@Covance.Com Thu Jun 7 19:27:26 2001 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Thu, 07 Jun 2001 13:27:26 -0500 Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding Message-ID: According to this recent blurb in "Dr. Dobbs' Python-URL" (a weekly "what's-new-in-Python" e-mail newsletter), there may be another possibility: """ How do you do serial IO in Python? Usual answer: It depends on your operating system. New answer: not anymore! XIO is a new cross-platform serial port driver for win32 and Unix. http://groups.google.com/groups?ic=1&th=dae9fa4438b9bc9a,3 """ Following the link, we learn more: "Currently, the module implements port creation, opening, closing, configuration, reading, writing & status peeking. It has been tested under Linux-x86 and Win-9X. It contains a naive implementation of flow control (and pretty untested -- so beware!)." Hope that helps! Curtis PS: To receive a new issue of "Dr. Dobbs" in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". >>> 06/07/2001 11:37:29 AM >>> Several weeks ago I posted a question about parsing data from a serial port. The data from the serial port uses a binary 3 to signal that it is through transmitting. Someone mentioned that the ExpectPy module might be a good candidate for parsing this data. Does anyone have a HOWTO for ExpectPy? Thanks! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that we can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From inkedmcse@yahoo.com Thu Jun 7 23:01:00 2001 From: inkedmcse@yahoo.com (Kelly Brett) Date: Thu, 7 Jun 2001 15:01:00 -0700 (PDT) Subject: [Tutor] python question... Message-ID: <20010607220100.74350.qmail@web11703.mail.yahoo.com> --0-195772596-991951260=:74165 Content-Type: text/plain; charset=us-ascii hello- i'm brand new to programming, and i'm very excited about learning python. I've used the "instant hacking" tutorial on the website, and it's making total sense. i'm just wondering how it is that somebody can get good at this stuff. i understand that practice makes perfect, but it just seems like there are so many directions that can be taken. so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me? thanks guys!! brett --------------------------------- Do You Yahoo!? Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail. --0-195772596-991951260=:74165 Content-Type: text/html; charset=us-ascii

hello-

i'm brand new to programming, and i'm very excited about learning python.  I've used the "instant hacking" tutorial on the website, and it's making total sense.  i'm just wondering how it is that somebody can get good at this stuff.  i understand that practice makes perfect, but it just seems like there are so many directions that can be taken. 

so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me?

thanks guys!!

brett



Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail. --0-195772596-991951260=:74165-- From glingl@aon.at Thu Jun 7 23:30:11 2001 From: glingl@aon.at (Gregor Lingl) Date: Fri, 08 Jun 2001 00:30:11 +0200 Subject: [Tutor] python question... References: <20010607220100.74350.qmail@web11703.mail.yahoo.com> Message-ID: <3B200073.E90320ED@aon.at> --------------6FC4330FBD56AB1883C7BF2A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit If you want to lern to program - using Python - try How to think like a computer scientist (http://www.ibiblio.org/obp/thinkCSpy/) Then to find more cooncrete material- exercises and so on ... - , go to Alan Gaulds's book on programming (http://members.nbci.com/alan_gauld/tutor/tutindex.htm) A very useful list of tutorials of each kind you find at Rob Andrews Tutorial Page (http://www.lowerstandard.com/python/tutoriallinks.html) on his Useless Python Site Good luck (and be patient!) Gregor L. Kelly Brett schrieb: hello- i'm brand new to programming, and i'm very excited about learning python. I've used the "instant hacking" tutorial on the website, and it's making total sense. i'm just wondering how it is that somebody can get good at this stuff. i understand that practice makes perfect, but it just seems like there are so many directions that can be taken. so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me? thanks guys!! brett Kelly Brett schrieb: > hello- > > i'm brand new to programming, and i'm very excited about learning > python. I've used the "instant hacking" tutorial on the website, and > it's making total sense. i'm just wondering how it is that somebody > can get good at this stuff. i understand that practice makes perfect, > but it just seems like there are so many directions that can be taken. > > so, beside the aforementioned tutorial, what is a good resource that > won't confuse the crap out of me? > > thanks guys!! > > brett > > > ----------------------------------------------------------------------- > Do You Yahoo!? > Yahoo! Mail Personal Address - Get email at your own domain with > Yahoo! Mail. --------------6FC4330FBD56AB1883C7BF2A Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit  
If you want to lern to program - using Python - try  How to think like a computer scientist
(http://www.ibiblio.org/obp/thinkCSpy/)

Then to find more cooncrete material- exercises and so on ... - , go to  Alan Gaulds's book on programming
(http://members.nbci.com/alan_gauld/tutor/tutindex.htm)

A very useful list of tutorials of each kind you find at Rob Andrews  Tutorial Page (http://www.lowerstandard.com/python/tutoriallinks.html) on his  Useless Python Site

Good luck (and be patient!)
Gregor L.

Kelly Brett schrieb:

  hello-

  i'm brand new to programming, and i'm very excited about learning python.  I've used the "instant hacking" tutorial on the website, and it's making total sense.  i'm just wondering how it is that
  somebody can get good at this stuff.  i understand that practice makes perfect, but it just seems like there are so many directions that can be taken.

  so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me?

  thanks guys!!

  brett
 
 
 

Kelly Brett schrieb:

hello-

i'm brand new to programming, and i'm very excited about learning python.  I've used the "instant hacking" tutorial on the website, and it's making total sense.  i'm just wondering how it is that somebody can get good at this stuff.  i understand that practice makes perfect, but it just seems like there are so many directions that can be taken.

so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me?

thanks guys!!

brett
 


Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.
--------------6FC4330FBD56AB1883C7BF2A-- From j_f9@yahoo.com Fri Jun 8 01:23:00 2001 From: j_f9@yahoo.com (F. Tourigny) Date: Thu, 7 Jun 2001 17:23:00 -0700 (PDT) Subject: [Tutor] sys._doc_ documentation Message-ID: <20010608002300.67711.qmail@web14506.mail.yahoo.com> I'm just starting with Programming Python, p. 16. Typing: sys._doc_ at the python prompt returns this message: Traceback (most recent call last): File "", line 1, in ? AttributeError: 'sys' module has no attribute '_doc_' However, "dir(sys)" is listing "_doc_" among the module's attributes. What gives? (Using ActivePython 2.1, Build 210) Greetings, Frederic __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From m.hadfield@niwa.cri.nz Fri Jun 8 01:28:39 2001 From: m.hadfield@niwa.cri.nz (Mark Hadfield) Date: Fri, 8 Jun 2001 12:28:39 +1200 Subject: [Tutor] sys._doc_ documentation References: <20010608002300.67711.qmail@web14506.mail.yahoo.com> Message-ID: <000401c0efb1$f7260dd0$d938a8c0@Hadfield> From: "F. Tourigny" > I'm just starting with Programming Python, p. 16. > Typing: > sys._doc_ > at the python prompt returns this message: > > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'sys' module has no attribute '_doc_' > > However, "dir(sys)" is listing "_doc_" among the > module's attributes. > What gives? > (Using ActivePython 2.1, Build 210) Works for me (below). You probably left off one of the underscores. ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.>>> import sys >>> import sys >>> sys.__doc__ "This module provides access to some objects used or maintained by the\ninterpre ter and to functions that interact strongly with the interpreter.\n\nDynamic obj ects:\n\nargv -- command line arguments; argv[0] is the script pathname if known \npath -- module search path; path[0] is the script directory, else ''\nmodules -- dictionary of loaded modules\n\ndisplayhook -- called to show results in an i nteractive session\nexcepthook -- called to handle any uncaught exception other than SystemExit\n To customize printing in an interactive session or to install a custom\n top-level exception handler, assign other functions to replace thes e.\n\nexitfunc -- if sys.exitfunc exists, this routine is called when Python exi ts\n Assigning to sys.exitfunc is deprecated; use the atexit module instead.\n\ .... --- Mark Hadfield m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From ak@silmarill.org Fri Jun 8 01:48:29 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Thu, 07 Jun 2001 20:48:29 -0400 Subject: [Tutor] sys._doc_ documentation In-Reply-To: <"from j_f9"@yahoo.com> References: <20010608002300.67711.qmail@web14506.mail.yahoo.com> Message-ID: <20010607204829.A421@sill.silmarill.org> On Thu, Jun 07, 2001 at 05:23:00PM -0700, F. Tourigny wrote: > I'm just starting with Programming Python, p. 16. > Typing: > sys._doc_ > at the python prompt returns this message: > > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'sys' module has no attribute '_doc_' > > However, "dir(sys)" is listing "_doc_" among the > module's attributes. > > What gives? > (Using ActivePython 2.1, Build 210) > > Greetings, > Frederic That's a typo, it should be sys.__doc__ . > > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail - only $35 > a year! http://personal.mail.yahoo.com/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Lime and limpid green a second scene A fight between the blue you once knew - Syd From amc1@dcs.qmw.ac.uk Fri Jun 8 15:41:03 2001 From: amc1@dcs.qmw.ac.uk (Allan Crooks) Date: Fri, 08 Jun 2001 15:41:03 +0100 Subject: [Tutor] Viewing __doc__ strings Message-ID: Hi, Is there anyway to make Python display __doc__ strings without all the "\n" characters? I know I could manually split it and then rejoin it, but surely there's an easier way? I'm using Python 2.1 on WinNT 4, if that's of any use. Thanks, Allan. From SBrunning@trisystems.co.uk Fri Jun 8 15:46:07 2001 From: SBrunning@trisystems.co.uk (Simon Brunning) Date: Fri, 8 Jun 2001 15:46:07 +0100 Subject: [Tutor] Viewing __doc__ strings Message-ID: <31575A892FF6D1118F5800600846864D78BD0D@intrepid> > From: Allan Crooks [SMTP:amc1@dcs.qmw.ac.uk] > Is there anyway to make Python display __doc__ strings without all the > "\n" characters? I know I could manually split it and then rejoin it, but > surely there's an easier way? Just use print. print whatever.__doc__ Cheers, Simon Brunning TriSystems Ltd. sbrunning@trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From scarblac@pino.selwerd.nl Fri Jun 8 15:55:14 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Fri, 8 Jun 2001 16:55:14 +0200 Subject: [Tutor] Viewing __doc__ strings In-Reply-To: ; from amc1@dcs.qmw.ac.uk on Fri, Jun 08, 2001 at 03:41:03PM +0100 References: Message-ID: <20010608165514.A23343@pino.selwerd.nl> On 0, Allan Crooks wrote: > Is there anyway to make Python display __doc__ strings without all the > "\n" characters? I know I could manually split it and then rejoin it, but > surely there's an easier way? print it: >>> len.__doc__ 'len(object) -> integer\n\nReturn the number of items of a sequence or mapping.' >>> print len.__doc__ len(object) -> integer Return the number of items of a sequence or mapping. Just like any other strings with \n's in them, really :) Personally I use a little doc() function that goes like this: def doc(x): print "Object:", `x` print if hasattr(x, '__doc__'): print "Docstring:" print x.__doc__ else: print "No docstring." So I can just type >>> doc(object) > I'm using Python 2.1 on WinNT 4, if that's of any use. On Linux I put that function in ~/.pythonrc, but I don't know where it goes on WinNT. There should be a file that's executed before you enter the interpreter. -- Remco Gerlich From iumarumo@eidosnet.co.uk Fri Jun 8 17:46:21 2001 From: iumarumo@eidosnet.co.uk (ibraheem umaru-mohammed) Date: Fri, 8 Jun 2001 17:46:21 +0100 Subject: [Tutor] Viewing __doc__ strings In-Reply-To: <20010608165514.A23343@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Fri, Jun 08, 2001 at 04:55:14PM +0200 References: <20010608165514.A23343@pino.selwerd.nl> Message-ID: <20010608174621.B5878@micromuse.com> [Remco Gerlich wrote...] -| On 0, Allan Crooks wrote: -| > Is there anyway to make Python display __doc__ strings without all the -| > "\n" characters? I know I could manually split it and then rejoin it, but -| > surely there's an easier way? -| -| print it: -| -| >>> len.__doc__ -| 'len(object) -> integer\n\nReturn the number of items of a sequence or mapping.' -| >>> print len.__doc__ -| len(object) -> integer -| -| Return the number of items of a sequence or mapping. -| -| Just like any other strings with \n's in them, really :) -| -| Personally I use a little doc() function that goes like this: -| -| def doc(x): -| print "Object:", `x` -| print -| if hasattr(x, '__doc__'): -| print "Docstring:" -| print x.__doc__ -| else: -| print "No docstring." -| -| So I can just type -| -| >>> doc(object) -| -| > I'm using Python 2.1 on WinNT 4, if that's of any use. -| -| On Linux I put that function in ~/.pythonrc, but I don't know where it goes -| on WinNT. There should be a file that's executed before you enter the -| interpreter. -| Or under Python 2.x >>>import pydoc >>>pydoc.doc(len) kindest regards, --ibs. -- Ibraheem Umaru-Mohammed ium@micromuse.com www.micromuse.com --0-- From pobrien@orbtech.com Fri Jun 8 16:54:11 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Fri, 8 Jun 2001 10:54:11 -0500 Subject: [Tutor] Viewing __doc__ strings In-Reply-To: <20010608165514.A23343@pino.selwerd.nl> Message-ID: I like that a lot. Very helpful when you are messing with something new in interactive mode. You inspired me to create my own variation. Hope everyone likes it. def doc(x): """Print type, representation and documentation string for object x.""" print "Object:", str(x) print "Object Type:", type(x) print "Representation:", repr(x) print "Documentation String:" print "---------------------" try: print x.__doc__ except AttributeError: print "This object does not have a documentation string." --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Remco Gerlich Sent: Friday, June 08, 2001 9:55 AM To: tutor@python.org Subject: Re: [Tutor] Viewing __doc__ strings Personally I use a little doc() function that goes like this: def doc(x): print "Object:", `x` print if hasattr(x, '__doc__'): print "Docstring:" print x.__doc__ else: print "No docstring." So I can just type >>> doc(object) > I'm using Python 2.1 on WinNT 4, if that's of any use. On Linux I put that function in ~/.pythonrc, but I don't know where it goes on WinNT. There should be a file that's executed before you enter the interpreter. -- Remco Gerlich _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From wall@adinet.com.uy Fri Jun 8 16:53:21 2001 From: wall@adinet.com.uy (Walter Moreira) Date: Fri, 8 Jun 2001 12:53:21 -0300 Subject: [Tutor] Viewing __doc__ strings In-Reply-To: ; from amc1@dcs.qmw.ac.uk on Fri, Jun 08, 2001 at 03:41:03PM +0100 References: Message-ID: <20010608125321.A29049@casa.parque> On Fri, Jun 08, 2001 at 03:41:03PM +0100, Allan Crooks wrote: > Hi, > > Is there anyway to make Python display __doc__ strings without all the "\n" characters? I know I could manually split it and then rejoin it, but surely there's an easier way? > > I'm using Python 2.1 on WinNT 4, if that's of any use. Use the pydoc module which is included in 2.1. For example: >>> def f(x): ... """A dummy function. ... It returns x. ... """ ... return x ... >>> f.__doc__ 'A dummy function.\n\tIt returns x.\n\t' >>> >>> from pydoc import help >>> help(f) Help on function f in module __main__: f(x) A dummy function. It returns x. pydoc is really cool!! Regards: Walter -- -------------- Walter Moreira <> Centro de Matematica <> Universidad de la Republica email: walterm@cmat.edu.uy <> HomePage: http://www.cmat.edu.uy/~walterm +----------------------------------------------------- /OD\_ | LEARNING, n. The kind of ignorance distinguishing O o . |_o_o_) | the studious. | -- Ambrose Bierce. Devil's Dictionary --+-- From rpm@wag.caltech.edu Fri Jun 8 17:10:12 2001 From: rpm@wag.caltech.edu (Richard P. Muller) Date: Fri, 08 Jun 2001 09:10:12 -0700 Subject: [Tutor] Re: python question References: Message-ID: <3B20F8E4.7B3F758E@wag.caltech.edu> > tutor-request@python.org wrote: > > Subject: [Tutor] python question... > Date: Thu, 7 Jun 2001 15:01:00 -0700 (PDT) > From: Kelly Brett > To: tutor@python.org > > hello- > > i'm brand new to programming, and i'm very excited about learning > python. I've used the "instant hacking" tutorial on the website, and > it's making total sense. i'm just wondering how it is that somebody > can get good at this stuff. i understand that practice makes perfect, > but it just seems like there are so many directions that can be > taken. > > so, beside the aforementioned tutorial, what is a good resource that > won't confuse the crap out of me? You already answered your question, in part. The way to get better at Python is simply to use it. Everywhere. Next time you have a simple repetitive task to do on the computer, think about how you could do it with Python. Hackers are generally lazy people, and would rather figure out an elegant programming solution to a problem rather than have to repeat some boring task over and over again. I like Lutz/Ascher's "Learning Python" as a good into. After a while you'll find all books rather limiting, though. Now I mostly just flip through the Library Reference from the Python docs. Some of the best advice anyone ever gave me was to "collect toys". Bill McCurdy (now at LBL) told me this, in regard to how to be a better computational chemist, but it applies to computer programming as well. Next time you hear about some interesting idea (such as XML), algorithm (such as quick sort), or program, rather than just read about it, code up a simple "toy" version of it. It's amazing how much more you learn when you actually try to program something -- it forces you to understand every facet of the idea rather than simply the jist. Rick From pobrien@orbtech.com Fri Jun 8 17:13:57 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Fri, 8 Jun 2001 11:13:57 -0500 Subject: [Tutor] Idea to help newbies - let's define 'help' Message-ID: Here is an idea. When you run the python interpreter in interactive mode for the very first time, it is probably pretty common to type the word 'help' just to see what happens. And guess what you get: >>> help Traceback (most recent call last): File "", line 1, in ? NameError: name 'help' is not defined >>> This is not exactly the friendliest response you and I could think of giving someone. (Especially if we want them to love Python the way we do.) So how about joining me in a little project here where we define 'help' for use in interactive mode? That means we need to create a script that will be pointed to by PYTHONSTARTUP or some other mechanism. The script (I'll suggest the name interactive.py) needs to contain useful functions like Remco Gerlich's doc() function as well as others. In addition, there needs to be a function named help() that will work with no parameters passed to it (at least none required). That's as far as I've gone with the idea. Anyone else interested? --- Patrick K. O'Brien Orbtech "I am, therefore I think." From pobrien@orbtech.com Fri Jun 8 17:54:58 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Fri, 8 Jun 2001 11:54:58 -0500 Subject: [Tutor] Idea to help newbies - let's define 'help' In-Reply-To: Message-ID: I see now that pydoc has 'help' defined and is probably the way to go. So one approach would be to just add 'from pydoc import help' to a startup script. Or we could try to reinvent the wheel and learn something along the way. I may do both. The pydoc technique is pretty cool in that help is actually an object, rather than simply a function: help = Helper(sys.stdin, sys.stdout) Helper is a custom class that does all kinds of things. Take a look at pydoc.py for more inspiration. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Friday, June 08, 2001 11:14 AM To: Python Tutor Subject: [Tutor] Idea to help newbies - let's define 'help' Here is an idea. When you run the python interpreter in interactive mode for the very first time, it is probably pretty common to type the word 'help' just to see what happens. And guess what you get: >>> help Traceback (most recent call last): File "", line 1, in ? NameError: name 'help' is not defined >>> This is not exactly the friendliest response you and I could think of giving someone. (Especially if we want them to love Python the way we do.) So how about joining me in a little project here where we define 'help' for use in interactive mode? That means we need to create a script that will be pointed to by PYTHONSTARTUP or some other mechanism. The script (I'll suggest the name interactive.py) needs to contain useful functions like Remco Gerlich's doc() function as well as others. In addition, there needs to be a function named help() that will work with no parameters passed to it (at least none required). That's as far as I've gone with the idea. Anyone else interested? --- Patrick K. O'Brien Orbtech "I am, therefore I think." _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From pobrien@orbtech.com Fri Jun 8 18:41:24 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Fri, 8 Jun 2001 12:41:24 -0500 Subject: [Tutor] PYTHONSTARTUP under Win98 Message-ID: I have a python script (.pythonrc.py) created and pointed to by PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos prompt and start python, the startup script is executed properly because the functions I defined in .pythonrc.py are available according to dir() and simply by using them. So everything is setup properly. However, nothing happens when I launch one of the IDEs, such as IDLE, PythonWin or Boa. I would have expected the interactive windows of these tools to have executed my startup script. I know they can "see" it because the following works: >>> dir() ['__builtins__', '__doc__', '__name__', 'pywin'] >>> import os >>> os.environ.get('PYTHONSTARTUP') 'C:\\My Documents\\pobrien\\.pythonrc.py' >>> execfile(os.environ.get('PYTHONSTARTUP')) >>> dir() ['__builtins__', '__doc__', '__name__', 'doc', 'help', 'os', 'pywin'] >>> So what gives? Is this the expected behavior? I just found an IDLE command line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help file. So maybe that is the case. --- Patrick K. O'Brien Orbtech "I am, therefore I think." From dyoo@hkn.eecs.berkeley.edu Sat Jun 9 08:06:10 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 9 Jun 2001 00:06:10 -0700 (PDT) Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: >> Is it practical and possible to have pydoc's help() function >> autoloaded by bundling a modified interpreter? > Yes, I've followed that discussion on the tutor list too. I think some > sort of interactive help would be great. I'm afraid modifying the > interpreter is a bit beyond me at this point, however. Making the CD > more interactive would be very cool, no doubt. Yahoo! We don't need to recompile at all: we just need to append the following to site.py within the library : ### ## (within site.py) ## Added by dyoo from pydoc import help __builtin__.help = help del help ### That will do it! Afterwards, help() will appear to be a builtin. I'll crosspost this to the tutor list; people were wondering about this one. This should definitely make things nicer for people. From dyoo@hkn.eecs.berkeley.edu Sat Jun 9 08:26:36 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 9 Jun 2001 00:26:36 -0700 (PDT) Subject: [Tutor] PYTHONSTARTUP under Win98 In-Reply-To: Message-ID: On Fri, 8 Jun 2001, Patrick K. O'Brien wrote: > I have a python script (.pythonrc.py) created and pointed to by > PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos prompt Python only looks at PYTHONSTARTUP if you run it as an interactive interpreter. That is, only when you run it through the dos prompt. It's one of those details that the official tutorial sorta whispers vaguely about... *grin* """ This file is only read in interactive sessions, not when Python reads commands from a script, and not when /dev/tty is given as the explicit source of commands (which otherwise behaves like an interactive session). """ http://www.python.org/doc/current/tut/node4.html#SECTION004230000000000000000 > So what gives? Is this the expected behavior? I just found an IDLE command > line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help > file. So maybe that is the case. Yes, you'll want to add the -s option to get IDLE to look at the $PYTHONSTARTUP variable. Another approach that we can use to get things to load automatically is to add some lines to the "site.py", which makes changes for everyone, regardless if we're running Python interactively or not. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Sat Jun 9 08:47:57 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 9 Jun 2001 00:47:57 -0700 (PDT) Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls In-Reply-To: Message-ID: On Wed, 6 Jun 2001, Patrick K. O'Brien wrote: > I think my question might not have been clear enough. I was wondering where > to put these functions on my local machine. For example, should I create a > file like utility.py and import that file into my other programs so I can > make use of these little utility functions, like my stripnull()? Does that > make sense? What do the rest of you do? I often keep a small personal directory filled with useful scripts that I've written. If a function seems a bit obscure, it goes into its own little file. Who knows --- a unoverlapping-genome-sequence-displayer.py might come in handy someday. *grin* If it seems general enough, it'll go into a file that's more generically named. For example, I put some of my string manipulating functions in a file called "MyStringUtils.py". You can probably make it more personal by putting your initials in the name somewhere... although I haven't done this myself, since "MyDy.py" looks a little silly. Finally, to make things nicer, I set my PYTHONPATH up so that those scripts are available at my fingertips. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Sat Jun 9 08:57:53 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 9 Jun 2001 00:57:53 -0700 (PDT) Subject: [Tutor] importing modules In-Reply-To: Message-ID: On Wed, 6 Jun 2001, Rik Klaver wrote: > I have downloaded some modules (or packages), which I've already put under > the 'Python21' folder in Win98. My problem is: Python lets me import some, > such as dynwin, pmw and pingo, but not the Mmtk20, Numeric and Htmlgen. For > some modules Python raises a SystemError. Hmmm... This is a little strange! Mmtk (The Molecular Modeling Toolkit) at: http://starship.python.net/crew/hinsen/MMTK/ says that it needs both ScientificPython and Numeric Python to get things running. At the same time, it looks like you might need the netCDF library too! Whew. This might be a little ugly. It might be good to get Numeric Python working first, and then get MmTk20 working. To get Scientific Python, try downloading here: http://basic.netmeg.net/godzilla/ You can download the netcdf and scientific_netcdf dll libraries, which you'll probably want to copy somewhere... can anyone give details on where it's supposed to go on Win98? I believe it should go within the site-packages/ directory, but I could be very wrong about this. About Htmlgen, hmmm... I'm not quite sure. Are you using WinZip to unzip the files? If so, you should have been ok; WinZip does the right thing with long file names. Can you tell us where exactly you're copying them to --- just in the Python21 folder, or in one of the smaller subfolders there? Installing new software is always a pain; I hope that this can be fixed quickly. Good luck to you! From arcege@speakeasy.net Sat Jun 9 13:01:34 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sat, 9 Jun 2001 08:01:34 -0400 (EDT) Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding In-Reply-To: <200106071637.f57GbTg11731@pop.nsacom.net> from "kromag@nsacom.net" at Jun 07, 2001 09:37:29 AM Message-ID: <200106091201.f59C1Yg01761@dsl092-074-184.bos1.dsl.speakeasy.net> kromag@nsacom.net wrote > Several weeks ago I posted a question about parsing data from a serial port. > The data from the serial port uses a binary 3 to signal that it is through > transmitting. Someone mentioned that the ExpectPy module might be a good > candidate for parsing this data. > > Does anyone have a HOWTO for ExpectPy? There is no HOWTO for ExpectPy (unless someone wrote one without telling the author). The original idea back when it was written four years ago was that it was a supplement to Expect, and that the user would probably be reading _Exploring Expect_. But then, that was a while ago. There are links to the Expect site with more info. What is it that you are looking for? -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From pobrien@orbtech.com Sat Jun 9 15:30:19 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 09:30:19 -0500 Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls In-Reply-To: Message-ID: That does help. I'm just so in love with Python's approach of having OneRightWay for everything that I'm trying to apply that to my own code. At every step I'm wondering, what is the OneRightWay for this? (Yes, I have been accused of being a bit anal.) If anyone else has a better OneRightWay to organize code I'm all ears. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Daniel Yoo Sent: Saturday, June 09, 2001 2:48 AM To: Patrick K. O'Brien Cc: Python Tutor Subject: RE: [Tutor] Utility functions - was: Best way to strip string string padded with nulls On Wed, 6 Jun 2001, Patrick K. O'Brien wrote: > I think my question might not have been clear enough. I was wondering where > to put these functions on my local machine. For example, should I create a > file like utility.py and import that file into my other programs so I can > make use of these little utility functions, like my stripnull()? Does that > make sense? What do the rest of you do? I often keep a small personal directory filled with useful scripts that I've written. If a function seems a bit obscure, it goes into its own little file. Who knows --- a unoverlapping-genome-sequence-displayer.py might come in handy someday. *grin* If it seems general enough, it'll go into a file that's more generically named. For example, I put some of my string manipulating functions in a file called "MyStringUtils.py". You can probably make it more personal by putting your initials in the name somewhere... although I haven't done this myself, since "MyDy.py" looks a little silly. Finally, to make things nicer, I set my PYTHONPATH up so that those scripts are available at my fingertips. Hope this helps! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From pobrien@orbtech.com Sat Jun 9 15:52:01 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 09:52:01 -0500 Subject: [Tutor] PYTHONSTARTUP under Win98 In-Reply-To: Message-ID: Thanks. I'm slowly catching on. The more I learn Python, the more impressed I am with the language ... and the more disappointed I am with the information about the environment. I think the setup and configuration of Python is still too big of a barrier for newbies. Python 2.1 and distutils has helped a lot, but there are still too many gotchas that get in the way. And if you want to be seriously productive you're going to want to control the python environment. For me, that means getting everything working the way I want it to in IDLE, PythonWin, Boa and VisualPython. And now you're telling me about site.py! Where the hell did that come from. I don't remember seeing anything about that!!! Okay, okay, I found it in the Python Essential Reference (excellent, excellent book). I'll have to read about it in order to reply. Thanks again for all your help. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Daniel Yoo Sent: Saturday, June 09, 2001 2:27 AM To: Patrick K. O'Brien Cc: Python Tutor Subject: Re: [Tutor] PYTHONSTARTUP under Win98 On Fri, 8 Jun 2001, Patrick K. O'Brien wrote: > I have a python script (.pythonrc.py) created and pointed to by > PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos prompt Python only looks at PYTHONSTARTUP if you run it as an interactive interpreter. That is, only when you run it through the dos prompt. It's one of those details that the official tutorial sorta whispers vaguely about... *grin* """ This file is only read in interactive sessions, not when Python reads commands from a script, and not when /dev/tty is given as the explicit source of commands (which otherwise behaves like an interactive session). """ http://www.python.org/doc/current/tut/node4.html#SECTION00423000000000000000 0 > So what gives? Is this the expected behavior? I just found an IDLE command > line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help > file. So maybe that is the case. Yes, you'll want to add the -s option to get IDLE to look at the $PYTHONSTARTUP variable. Another approach that we can use to get things to load automatically is to add some lines to the "site.py", which makes changes for everyone, regardless if we're running Python interactively or not. Hope this helps! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From pobrien@orbtech.com Sat Jun 9 15:52:03 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 09:52:03 -0500 Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: Cool idea. Could I suggest a small change, though? The documentation for site says this: "After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored." So would it make more sense to create a sitecustomize.py file with your code? I'm going to give it a try, as soon as I have another cup of coffee. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Daniel Yoo Sent: Saturday, June 09, 2001 2:06 AM To: Timothy Wilson Cc: Python-Edu SIG; tutor@python.org Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] >> Is it practical and possible to have pydoc's help() function >> autoloaded by bundling a modified interpreter? > Yes, I've followed that discussion on the tutor list too. I think some > sort of interactive help would be great. I'm afraid modifying the > interpreter is a bit beyond me at this point, however. Making the CD > more interactive would be very cool, no doubt. Yahoo! We don't need to recompile at all: we just need to append the following to site.py within the library : ### ## (within site.py) ## Added by dyoo from pydoc import help __builtin__.help = help del help ### That will do it! Afterwards, help() will appear to be a builtin. I'll crosspost this to the tutor list; people were wondering about this one. This should definitely make things nicer for people. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From pobrien@orbtech.com Sat Jun 9 16:18:41 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 10:18:41 -0500 Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: Here is the code in site.py that attempts to load sitecustomize.py. As you can gather, sitecustomize.py will have to be on the PYTHONPATH in order to be found, which limits where the file can be located. # # Run custom site specific code, if available. # try: import sitecustomize except ImportError: pass Site.py lives in the Lib directory, so that might be one place to put sitecustomize.py. I don't like that because I like to keep customizations separate from standard Python stuff. So I will probably put this into one of my own personal directories. But that doesn't work as a standard approach. Now that I've played with this I actually like Daniel Yoo's original suggestion the best. Maybe someone should suggest to Guido and company that Daniel's change to site.py be added to the standard distribution. There is something of a precedent in that site.py includes some code to define responses to some other terms (see code below). Anyone know how to submit a PEP? --- snipped from site.py as support for PEP XXXXX --- # Define new built-ins 'quit' and 'exit'. # These are simply strings that display a hint on how to exit. if os.sep == ':': exit = 'Use Cmd-Q to quit.' elif os.sep == '\\': exit = 'Use Ctrl-Z plus Return to exit.' else: exit = 'Use Ctrl-D (i.e. EOF) to exit.' import __builtin__ __builtin__.quit = __builtin__.exit = exit del exit --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Saturday, June 09, 2001 9:52 AM To: Python-Edu SIG; tutor@python.org Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] Cool idea. Could I suggest a small change, though? The documentation for site says this: "After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored." So would it make more sense to create a sitecustomize.py file with your code? I'm going to give it a try, as soon as I have another cup of coffee. --- Patrick K. O'Brien Orbtech "I am, therefore I think." From pobrien@orbtech.com Sat Jun 9 17:16:21 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 11:16:21 -0500 Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: I gave this a try (Adding Daniel's code to sitecustomize.py) and it didn't quite work. Some stuff did and some didn't. As you can see from the sample session below, help on a specific function works, but help with no parameters does not. Weird. Daniel's code works when entered interactively but not when loaded from sitecustomize.py. So then I tried the original suggestion to add it to site.py and I get the same behavior. Can anyone else confirm this? Daniel? I ran this on Win98SE with Python 2.1. --- >>> help Traceback (most recent call last): File "", line 1, in ? File "c:\python21\lib\pydoc.py", line 1276, in __repr__ self() File "c:\python21\lib\pydoc.py", line 1285, in __call__ self.interact() File "c:\python21\lib\pydoc.py", line 1297, in interact self.output.flush() IOError: [Errno 9] Bad file descriptor >>> help(len) Help on built-in function len: len(...) len(object) -> integer Return the number of items of a sequence or mapping. >>> --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Saturday, June 09, 2001 9:52 AM To: Python-Edu SIG; tutor@python.org Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] Cool idea. Could I suggest a small change, though? The documentation for site says this: "After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored." So would it make more sense to create a sitecustomize.py file with your code? I'm going to give it a try, as soon as I have another cup of coffee. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Daniel Yoo Sent: Saturday, June 09, 2001 2:06 AM To: Timothy Wilson Cc: Python-Edu SIG; tutor@python.org Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] >> Is it practical and possible to have pydoc's help() function >> autoloaded by bundling a modified interpreter? > Yes, I've followed that discussion on the tutor list too. I think some > sort of interactive help would be great. I'm afraid modifying the > interpreter is a bit beyond me at this point, however. Making the CD > more interactive would be very cool, no doubt. Yahoo! We don't need to recompile at all: we just need to append the following to site.py within the library : ### ## (within site.py) ## Added by dyoo from pydoc import help __builtin__.help = help del help ### That will do it! Afterwards, help() will appear to be a builtin. I'll crosspost this to the tutor list; people were wondering about this one. This should definitely make things nicer for people. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig From pobrien@orbtech.com Sat Jun 9 17:34:53 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sat, 9 Jun 2001 11:34:53 -0500 Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: Just to be thoroughly anal about this whole thing, I added the following code to my .pythonrc.py PYTHONSTARTUP file: import __builtin__ from pydoc import help __builtin__.help = help del help del __builtin__ When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the -s command line switch, help is added to builtin and works completely fine (see below for sample output). I must admit, I'm not sure I understand the advantage of having help be a builtin versus having it be just 'from pydoc import help' except that the latter did nothing when I tried it as part of site.py. So I imagine there are namespace things going on that I don't fully understand. --- Here is what 'help' at the python prompt should look like: --- >>> help Welcome to Python 2.1! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://www.python.org/doc/tut/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". help> --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Saturday, June 09, 2001 11:16 AM To: Python-Edu SIG; tutor@python.org Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] I gave this a try (Adding Daniel's code to sitecustomize.py) and it didn't quite work. Some stuff did and some didn't. As you can see from the sample session below, help on a specific function works, but help with no parameters does not. Weird. Daniel's code works when entered interactively but not when loaded from sitecustomize.py. So then I tried the original suggestion to add it to site.py and I get the same behavior. Can anyone else confirm this? Daniel? I ran this on Win98SE with Python 2.1. --- >>> help Traceback (most recent call last): File "", line 1, in ? File "c:\python21\lib\pydoc.py", line 1276, in __repr__ self() File "c:\python21\lib\pydoc.py", line 1285, in __call__ self.interact() File "c:\python21\lib\pydoc.py", line 1297, in interact self.output.flush() IOError: [Errno 9] Bad file descriptor >>> help(len) Help on built-in function len: len(...) len(object) -> integer Return the number of items of a sequence or mapping. >>> --- Patrick K. O'Brien Orbtech "I am, therefore I think." From kromag@nsacom.net Sun Jun 10 07:35:11 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Sat, 9 Jun 2001 23:35:11 -0700 (PDT) Subject: [Tutor] PosixSerial.py seems to be missing.... Message-ID: <200106100635.f5A6ZBg21652@pop.nsacom.net> Does anyone know of a mirror for the PosixSerial.py module? The link at Vaults of Parnassus is dead. (http://members.tripod.com/~gcavazos/) Thanks! d From allan.crooks@btinternet.com Sun Jun 10 15:28:38 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Sun, 10 Jun 2001 15:28:38 +0100 Subject: [Tutor] Central Python Library / Viewing __doc__ strings Message-ID: Hi, First off, thanks to everyone who responded to my message. Needless to say, I feel somewhat stupid for not trying print. :) Thanks for the scripts people sent as well. I'm growing somewhat fond of Patrick's however, so I'll probably use that over Pydoc's. Thanks very much Patrick. :) BTW, does anyone know how Pydoc retrieves the arg list for functions when you use help? e.g. >>> def t(x,y,s,ll,m,f=None,n=2): .. print x,y,s,ll,m,f,n >>> pydoc.help(t) Help on function t in module __main__: t(x, y, s, ll, m, f=None, n=2) Which now brings me to my next question: Is there a central repository of functions that exist somewhere? Something like a utility module? It just seems a shame for all these methods to just float around without having a home of some sort... Thanks again, Allan. From pobrien@orbtech.com Sun Jun 10 16:16:21 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sun, 10 Jun 2001 10:16:21 -0500 Subject: [Tutor] Central Python Library / Viewing __doc__ strings In-Reply-To: Message-ID: You are most welcome. If you are interested, here is the latest version of my startup file (.pythonrc.py): from pydoc import help from pprint import pprint def doc(x): """Print type, representation and documentation string for object x.""" print "Object:", str(x) print "Object Type:", type(x) print "Representation:", repr(x) print "Documentation String:" print "---------------------" try: print x.__doc__ except AttributeError: print "This object does not have a documentation string." # Let the user know that this file has been loaded by their IDE. # If it doesn't get loaded they won't see the following message. import os print "---" print "Python Startup file (%s) was loaded." % os.environ.get('PYTHONSTARTUP') print "---" del os --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Allan Crooks Sent: Sunday, June 10, 2001 9:29 AM To: tutor@python.org Subject: [Tutor] Central Python Library / Viewing __doc__ strings Hi, First off, thanks to everyone who responded to my message. Needless to say, I feel somewhat stupid for not trying print. :) Thanks for the scripts people sent as well. I'm growing somewhat fond of Patrick's however, so I'll probably use that over Pydoc's. Thanks very much Patrick. :) From pobrien@orbtech.com Sun Jun 10 17:12:09 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sun, 10 Jun 2001 11:12:09 -0500 Subject: [Tutor] Central Python Library / Viewing __doc__ strings In-Reply-To: Message-ID: Not entirely sure what you are looking for, but here are some suggestions anyway: 1. Type dir() to see a list of stuff in the current namespace. Type dir([object]) to get a list of attributes/methods/functions for an object. For example: >>> import pydoc >>> dir(pydoc) ['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper', 'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__', '__builtins__', '__credits__', '__date__', '__doc__', '__file__', '__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli', 'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager', 'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata', 'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager', 'pathdirs', 'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip', 'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid', 'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types', 'writedoc', 'writedocs'] >>> 2. Look in the documentation at the module index to see all the modules and the functions defined in each (http://www.python.org/doc/current/modindex.html). Or try the index (http://www.python.org/doc/current/lib/genindex.html). Let me know if I am way off base because I'm sure I probably misunderstood the question. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Allan Crooks Sent: Sunday, June 10, 2001 9:29 AM To: tutor@python.org Subject: [Tutor] Central Python Library / Viewing __doc__ strings Hi, Which now brings me to my next question: Is there a central repository of functions that exist somewhere? Something like a utility module? It just seems a shame for all these methods to just float around without having a home of some sort... Thanks again, Allan. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From allan.crooks@btinternet.com Sun Jun 10 18:09:43 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Sun, 10 Jun 2001 18:09:43 +0100 Subject: [Tutor] Central Python Library / Viewing __doc__ strings Message-ID: Thanks for the information, but yes, there was a bit of a misunderstanding. :) What I meant was is there any kind of place where code that we've written can become easily public domain? For example, I've written a piece of code that denests lists, tuples, and any other sequence type (it's better than I've described it, honest). It's currently sitting at home, not publicly available. I could put it online, but I doubt anyone would really be interested in it on it's own (they could probably write something in the time it takes to actually find it). But if there was some place where little pieces of code was collected together and put in the public domain, so that people could find it more easily, and people could use this utility module to use several little functions (to save time coding their own). I think Useless Python is the closest that I've come to it, but I think I'm looking for a place to submit generic functions. I may just end up putting my own repository of code online anyway...... Just wondered if there was a way I could donate my code for the "greater good" really. :) Thanks anyway, Allan. > Not entirely sure what you are looking for, but here are some suggestions > anyway: > > 1. Type dir() to see a list of stuff in the current namespace. Type > dir([object]) to get a list of attributes/methods/functions for an object. > For example: > > >>> import pydoc > >>> dir(pydoc) > ['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper', > 'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__', > '__builtins__', '__credits__', '__date__', '__doc__', '__file__', > '__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli', > 'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager', > 'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata', > 'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager', 'pathdirs', > 'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip', > 'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid', > 'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types', 'writedoc', > 'writedocs'] > >>> > > 2. Look in the documentation at the module index to see all the modules and > the functions defined in each > (http://www.python.org/doc/current/modindex.html). Or try the index > (http://www.python.org/doc/current/lib/genindex.html). > > > Let me know if I am way off base because I'm sure I probably misunderstood > the question. > > --- > Patrick K. O'Brien > Orbtech > "I am, therefore I think." > > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Allan Crooks > Sent: Sunday, June 10, 2001 9:29 AM > To: tutor@python.org > Subject: [Tutor] Central Python Library / Viewing __doc__ strings > > Hi, > > > > Which now brings me to my next question: Is there a central repository of > functions that exist somewhere? Something like a utility module? It just > seems a shame for all these methods to just float around without having a > home of some sort... > > Thanks again, > Allan. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > From pobrien@orbtech.com Sun Jun 10 18:28:07 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sun, 10 Jun 2001 12:28:07 -0500 Subject: [Tutor] Central Python Library / Viewing __doc__ strings In-Reply-To: Message-ID: Ah, yes. That code sounds interesting. I wouldn't mind seeing it myself. I think I might have a need for something like that, actually. Useless Python is a great spot for something like this and the Python Cookbook is as well (http://aspn.activestate.com/ASPN/Python/Cookbook/). I think the Python Cookbook is exactly what you were looking for. See what you think. In the mean time, I'd love a copy of the code. Thanks. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Allan Crooks Sent: Sunday, June 10, 2001 12:10 PM To: tutor@python.org Subject: RE: [Tutor] Central Python Library / Viewing __doc__ strings Thanks for the information, but yes, there was a bit of a misunderstanding. :) What I meant was is there any kind of place where code that we've written can become easily public domain? For example, I've written a piece of code that denests lists, tuples, and any other sequence type (it's better than I've described it, honest). It's currently sitting at home, not publicly available. I could put it online, but I doubt anyone would really be interested in it on it's own (they could probably write something in the time it takes to actually find it). But if there was some place where little pieces of code was collected together and put in the public domain, so that people could find it more easily, and people could use this utility module to use several little functions (to save time coding their own). I think Useless Python is the closest that I've come to it, but I think I'm looking for a place to submit generic functions. I may just end up putting my own repository of code online anyway...... Just wondered if there was a way I could donate my code for the "greater good" really. :) Thanks anyway, Allan. > Not entirely sure what you are looking for, but here are some suggestions > anyway: > > 1. Type dir() to see a list of stuff in the current namespace. Type > dir([object]) to get a list of attributes/methods/functions for an object. > For example: > > >>> import pydoc > >>> dir(pydoc) > ['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper', > 'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__', > '__builtins__', '__credits__', '__date__', '__doc__', '__file__', > '__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli', > 'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager', > 'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata', > 'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager', 'pathdirs', > 'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip', > 'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid', > 'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types', 'writedoc', > 'writedocs'] > >>> > > 2. Look in the documentation at the module index to see all the modules and > the functions defined in each > (http://www.python.org/doc/current/modindex.html). Or try the index > (http://www.python.org/doc/current/lib/genindex.html). > > > Let me know if I am way off base because I'm sure I probably misunderstood > the question. > > --- > Patrick K. O'Brien > Orbtech > "I am, therefore I think." > > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Allan Crooks > Sent: Sunday, June 10, 2001 9:29 AM > To: tutor@python.org > Subject: [Tutor] Central Python Library / Viewing __doc__ strings > > Hi, > > > > Which now brings me to my next question: Is there a central repository of > functions that exist somewhere? Something like a utility module? It just > seems a shame for all these methods to just float around without having a > home of some sort... > > Thanks again, > Allan. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From dyoo@hkn.eecs.berkeley.edu Sun Jun 10 18:26:05 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 10 Jun 2001 10:26:05 -0700 (PDT) Subject: [Tutor] Central Python Library / Viewing __doc__ strings In-Reply-To: Message-ID: On Sun, 10 Jun 2001, Allan Crooks wrote: > I think Useless Python is the closest that I've come to it, but I > think I'm looking for a place to submit generic functions. I may just > end up putting my own repository of code online anyway...... Just > wondered if there was a way I could donate my code for the "greater > good" really. :) The Vaults of Parnassus is one of the "official" repositories for Python code: http://www.vex.net/parnassus Another place that might be relevant is the Python Cookbook, maintained here: http://aspn.activestate.com/ASPN/Cookbook/Python Hope this helps! From rob@jam.rr.com Sun Jun 10 18:32:07 2001 From: rob@jam.rr.com (Rob Andrews) Date: Sun, 10 Jun 2001 12:32:07 -0500 Subject: [Tutor] Central Python Library / Viewing __doc__ strings References: Message-ID: <3B23AF17.A580EBF@jam.rr.com> Allan Crooks wrote: > > Thanks for the information, but yes, there was a bit of a misunderstanding. :) > > What I meant was is there any kind of place where code that we've written can become easily public domain? > > For example, I've written a piece of code that denests lists, tuples, and any other sequence type (it's better than I've described it, honest). It's currently sitting at home, not publicly available. I could put it online, but I doubt anyone would really be interested in it on it's own (they could probably write something in the time it takes to actually find it). > > But if there was some place where little pieces of code was collected together and put in the public domain, so that people could find it more easily, and people could use this utility module to use several little functions (to save time coding their own). > > I think Useless Python is the closest that I've come to it, but I think I'm looking for a place to submit generic functions. I may just end up putting my own repository of code online anyway...... Just wondered if there was a way I could donate my code for the "greater good" really. :) > > Thanks anyway, > Allan. > Of course your code is always welcome at Useless Python (which I just gave Yet Another face-lift, including quotes from some of you). I encourage people to send material to Useless, the Vaults, the Cookbook, and anywhere else you care to. Although many of us look at CPAN with just a hint of envy, I like the fact that Useless, the Vaults, and the Cookbook are actually quite different from each other. After all, There's More Than One Way To Do It! (Oh, wait.... That's Perl again.) Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From dyoo@hkn.eecs.berkeley.edu Sun Jun 10 18:37:50 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 10 Jun 2001 10:37:50 -0700 (PDT) Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: On Sat, 9 Jun 2001, Patrick K. O'Brien wrote: > import __builtin__ > from pydoc import help > __builtin__.help = help > del help > del __builtin__ > > When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the > -s command line switch, help is added to builtin and works completely > fine (see below for sample output). Ah, good! I'm glad it's working now. > I must admit, I'm not sure I understand the advantage of having help > be a builtin versus having it be just 'from pydoc import help' except > that the latter did nothing when I tried it as part of site.py. So I > imagine there are namespace things going on that I don't fully > understand. It's a namespacing issue: if we do the "from pydoc import help", then help()'s visible from the 'site' module, since that's where it's being imported into. However, it's not visible anywhere outside, and that's the big problem. We can do a small example to explore this if you want. It's an extension of the "local variables" idea, but instead of functions, it uses whole files (modules) as the containers. The way the code gets around this isolating behavior is it grabs the __builtin__ module, which is actually just a big container for all the built-in functions that Python makes available to us globally. ### >>> import __builtin__ >>> dir(__builtin__) ['ArithmeticError', 'AssertionError', 'AttributeError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'FloatingPointError', 'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'oct', 'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'] ### The code snippet that we have: > import __builtin__ > from pydoc import help > __builtin__.help = help is meant to stuff our help function() alongside those other functions. [about the unsuccessful approach in sitecustomize.py] > but not when loaded from sitecustomize.py. So then I tried the original > suggestion to add it to site.py and I get the same behavior. Can anyone else > confirm this? Daniel? I ran this on Win98SE with Python 2.1. Hmmm! I haven't been able to confirm this; I don't have Windows on this laptop. I'll see if I can check this on Win2k when I get home though. From pobrien@orbtech.com Sun Jun 10 18:41:01 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sun, 10 Jun 2001 12:41:01 -0500 Subject: [Tutor] Central Python Library / Viewing __doc__ strings In-Reply-To: Message-ID: First, the short answer. It's all in the inspect module: >>> import inspect >>> inspect.getargspec(t) (['x', 'y', 's', 'll', 'm', 'f', 'n'], None, None, (None, 2)) That gets you part of the way. Then you need to do some formatting: >>> inspect.formatargspec(inspect.getargspec(t)) '((x, y, s, ll, m, f, n), None, None, (None, 2))' Then you'll need to spend a few hours dissecting the inspect module to figure out everything that goes on to get the arguments and produce the final formatting that help(t) shows. (Because I'm too tired to do it myself and I'm already in trouble with the wife for spending all morning on this. ) Now for the long(er) answer. Here is the relevant method from pydoc.py. It is part of the Helper class defined in pydoc: def help(self, request): if type(request) is type(''): if request == 'help': self.intro() elif request == 'keywords': self.listkeywords() elif request == 'topics': self.listtopics() elif request == 'modules': self.listmodules() elif request[:8] == 'modules ': self.listmodules(split(request)[1]) elif self.keywords.has_key(request): self.showtopic(request) elif self.topics.has_key(request): self.showtopic(request) elif request: doc(request, 'Help on %s:') elif isinstance(request, Helper): self() else: doc(request, 'Help on %s:') self.output.write('\n') So calling help on an object results in a call to doc(object, 'Help on %s:'). Doc() is a function that looks like: def doc(thing, title='Python Library Documentation: %s', forceload=0): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing, forceload) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s' % repr(thing) return parts = split(thing, '.') if len(parts) > 1: suffix = ' in ' + join(parts[:-1], '.') name = parts[-1] thing = object desc = describe(thing) module = inspect.getmodule(thing) if not suffix and module and module is not thing: suffix = ' in module ' + module.__name__ pager(title % (desc + suffix) + '\n\n' + text.document(thing, name)) The last bit of code - text.document(thing, name) - is what we need to explore. Doc() gets documentation on the thing with the document() method of the TextDoc class (which is a child of the Doc class and the document method is actually defined in the Doc class, not in TextDoc): class Doc: def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object, name) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) return apply(self.docother, args) Since in your example t is a function (inspect.isroutine(t) will return 1, or true), we need to look at self.docroutine: class TextDoc(Doc): ... def docroutine(self, object, name=None, mod=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: note = ' from ' + classname(imclass, mod) skipdocs = 1 else: if object.im_self: note = ' method of %s instance' % classname( object.im_self.__class__, mod) else: note = ' unbound %s method' % classname(imclass,mod) object = object.im_func if name == realname: title = self.bold(realname) else: if (cl and cl.__dict__.has_key(realname) and cl.__dict__[realname] is object): skipdocs = 1 title = self.bold(name) + ' = ' + realname if inspect.isbuiltin(object): argspec = '(...)' else: args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) if realname == '': title = 'lambda' argspec = argspec[1:-1] # remove parentheses decl = title + argspec + note if skipdocs: return decl + '\n' else: doc = getdoc(object) or '' return decl + '\n' + (doc and rstrip(self.indent(doc)) + '\n') Now, this is a lot of code to look at, but the answer to your question lies with inspect.getargspec(object). If we run that bit of code on t we get the following: >>> inspect.getargspec(t) (['x', 'y', 's', 'll', 'm', 'f', 'n'], None, None, (None, 2)) >>> The rest of the code makes things a prettier. Again, that analysis will be left as an exercise for the reader. Hope that answered your question. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Allan Crooks Sent: Sunday, June 10, 2001 9:29 AM To: tutor@python.org Subject: [Tutor] Central Python Library / Viewing __doc__ strings BTW, does anyone know how Pydoc retrieves the arg list for functions when you use help? e.g. >>> def t(x,y,s,ll,m,f=None,n=2): .. print x,y,s,ll,m,f,n >>> pydoc.help(t) Help on function t in module __main__: t(x, y, s, ll, m, f=None, n=2) Thanks again, Allan. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From pobrien@orbtech.com Sun Jun 10 19:22:07 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Sun, 10 Jun 2001 13:22:07 -0500 Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] In-Reply-To: Message-ID: Just to clarify a tiny bit. (I hope) Adding help to the builtins works from my PYTHONSTARTUP file, but not from site.py or sitecustomize.py. So it doesn't really have any advantage over 'from pydoc import help' when loaded this way, does it? If it will only work properly from the startup file, I feel that "from pydoc import help" is just as good an approach. In fact, it has the advantage of being listed in dir() and not buried in __builtins__. Or am I missing something? I think I understand the namespace concept pretty well. (I hope. ) What I don't understand is why the module pointed to by PYTHONSTARTUP is part of the global namespace (which is why we can just do 'from pydoc import help' in it, and the help function stays around) while site.py is not (so while 'from pydoc import help' works it also "disappears" once control goes to the interactive prompt, unless we do the __builtin__ trick). Well, I do understand why it works that way for the startup file. It just seemed like it would work the same for site.py, based on the (skimpy) documentation. So my confusion has more to do with a lack of documented behavior, rather than the behavior itself, if that makes any sense. And maybe the answer is just "because". Other than that, I understand and agree with everything you say below. I just wish I knew why your suggested code doesn't entirely work in site.py. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Daniel Yoo Sent: Sunday, June 10, 2001 12:38 PM To: Patrick K. O'Brien Cc: tutor@python.org Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin] On Sat, 9 Jun 2001, Patrick K. O'Brien wrote: > import __builtin__ > from pydoc import help > __builtin__.help = help > del help > del __builtin__ > > When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the > -s command line switch, help is added to builtin and works completely > fine (see below for sample output). Ah, good! I'm glad it's working now. > I must admit, I'm not sure I understand the advantage of having help > be a builtin versus having it be just 'from pydoc import help' except > that the latter did nothing when I tried it as part of site.py. So I > imagine there are namespace things going on that I don't fully > understand. It's a namespacing issue: if we do the "from pydoc import help", then help()'s visible from the 'site' module, since that's where it's being imported into. However, it's not visible anywhere outside, and that's the big problem. We can do a small example to explore this if you want. It's an extension of the "local variables" idea, but instead of functions, it uses whole files (modules) as the containers. The way the code gets around this isolating behavior is it grabs the __builtin__ module, which is actually just a big container for all the built-in functions that Python makes available to us globally. ### >>> import __builtin__ >>> dir(__builtin__) ['ArithmeticError', 'AssertionError', 'AttributeError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'FloatingPointError', 'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'oct', 'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'] ### The code snippet that we have: > import __builtin__ > from pydoc import help > __builtin__.help = help is meant to stuff our help function() alongside those other functions. [about the unsuccessful approach in sitecustomize.py] > but not when loaded from sitecustomize.py. So then I tried the original > suggestion to add it to site.py and I get the same behavior. Can anyone else > confirm this? Daniel? I ran this on Win98SE with Python 2.1. Hmmm! I haven't been able to confirm this; I don't have Windows on this laptop. I'll see if I can check this on Win2k when I get home though. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From dyoo@hkn.eecs.berkeley.edu Sun Jun 10 20:46:47 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 10 Jun 2001 12:46:47 -0700 (PDT) Subject: [Tutor] PosixSerial.py seems to be missing.... In-Reply-To: <200106100635.f5A6ZBg21652@pop.nsacom.net> Message-ID: On Sat, 9 Jun 2001 kromag@nsacom.net wrote: > Does anyone know of a mirror for the PosixSerial.py module? The link at > Vaults of Parnassus is dead. (http://members.tripod.com/~gcavazos/) Ouch! I haven't been able to find this either; you may want to ask the comp.lang.python folks and bring this to their attention. From israel@lith.com Sun Jun 10 21:35:19 2001 From: israel@lith.com (Israel Evans) Date: Sun, 10 Jun 2001 13:35:19 -0700 Subject: [Tutor] request: info on AI and related subjects for Python Message-ID: Has anyone found any good information on applying Python to AI/Neural network yada yada programming and whether or not it's a good idea? ~Israel~ From lumbricus@gmx.net Sun Jun 10 22:49:06 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sun, 10 Jun 2001 23:49:06 +0200 Subject: [Tutor] request: info on AI and related subjects for Python In-Reply-To: ; from israel@lith.com on Sun, Jun 10, 2001 at 01:35:19PM -0700 References: Message-ID: <20010610234906.A14085@Laplace.localdomain> On Sun, Jun 10, 2001 at 01:35:19PM -0700, Israel Evans wrote: > Has anyone found any good information on applying Python to AI/Neural > network yada yada programming and whether or not it's a good idea? > "http://www.ai.uga.edu/~jae/ai.html" "http://www-acs.ucsd.edu/~jstrout/python/ai/" > > ~Israel~ > HTH J! > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Colorless green ideas sleep furiously. From InternetShops@mail.ru Mon Jun 11 00:22:30 2001 From: InternetShops@mail.ru (InternetShops@mail.ru) Date: Mon, 11 Jun 2001 01:22:30 +0200 Subject: [Tutor] úáëáú îáäåöîïçï ïâïòõäï÷áîéñ þåòåú éîôåòîåô Message-ID: <200106102322.f5ANMUM14499@friedrich.unkelhaeuser.de> This is a MIME encoded message. --b21fe52ec73da2129e8a6323ced0b8f49 Content-Type: text/html ; charset="windows-1251" Content-Transfer-Encoding: base64 PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv L0VOIj4NCg0KPGh0bWw+DQo8aGVhZD4NCgk8dGl0bGU+x8DKwMcgzcDExcbNzsPOIM7BztDTxM7C wM3I3yDXxdDFxyDIzdLF0M3F0jwvdGl0bGU+DQo8L2hlYWQ+DQoNCjxib2R5Pg0KPGRpdiBhbGln bj0iQ0VOVEVSIj4NCjxoMj7V7vDu+OXlIO7h7vDz5O7i4O3o5SDs7ubt7iDq8+/o8vwsIOfg6uDn 4OIg9+Xw5ecgyO3y5fDt5fI6PC9oMj4NCjx0YWJsZT4NCjx0cj4NCgk8dGQ+PGI+yu7s7/z+8uXw +zo8L2I+PC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxhIGhyZWY9Imh0dHA6Ly93d3cudmlzdC5y dUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9dmlzdC5y dSI+dmlzdC5ydTwvYT48YnI+DQoJPGEgaHJlZj0iaHR0cDovL3d3dy5rbG9uZGFpay5ydUB3d3cu amFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD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1Ij5taXRhLnJ1PC9hPjwvdGQ+DQo8L3RyPg0KPHRyPg0KCTx0ZD48YSBocmVmPSJo dHRwOi8vd3d3Lm1hcnZlbC5ydUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBw eXRob24ub3JnJnM9bWFydmVsLnJ1Ij5tYXJ2ZWwucnU8L2E+PC90ZD4NCjwvdHI+DQo8dHI+DQoJ PHRkPjxhIGhyZWY9Imh0dHA6Ly93d3cuc2NvcHkucnVAd3d3Lmphbi1oZW5kcmlrLmNvbS9yZXMu cGhwP3Q9dHV0b3JAcHl0aG9uLm9yZyZzPXNjb3B5LnJ1Ij5zY29weS5ydTwvYT48L3RkPg0KPC90 cj4NCjwvdGFibGU+DQoNCjwvZGl2Pg0KPC9ib2R5Pg0KPC9odG1sPg0K --b21fe52ec73da2129e8a6323ced0b8f49-- From dyoo@hkn.eecs.berkeley.edu Mon Jun 11 03:03:09 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 10 Jun 2001 19:03:09 -0700 (PDT) Subject: [Tutor] request: info on AI and related subjects for Python In-Reply-To: Message-ID: On Sun, 10 Jun 2001, Israel Evans wrote: > Has anyone found any good information on applying Python to AI/Neural > network yada yada programming and whether or not it's a good idea? Peter Norvig, one of the authors of the textbook, "Artifical Inteligence: A Modern Approach", has a small page about Python in his AI programming. His page is here: http://www.norvig.com/python-lisp.html This isn't quite what you're looking for though, because it only explains the differences between Lisp and Python. It sounds like you're more interested in actual applications of AI stuff. Parnassus does have some links to AI programs. For example, there are some neural net implementations here: http://www.vex.net/parnassus/apyllo.py?find=neural+net If you want something more input about this, you might want to talk with people on comp.lang.python as well; I believe that Mark Lutz or one of the other Python authors has written expert system shells in Python, so Python seems to be a reasonable language for certain AI applications. Anyway, hope this helps! From bcarey@ix.netcom.com Mon Jun 11 03:47:40 2001 From: bcarey@ix.netcom.com (William N Carey) Date: Sun, 10 Jun 2001 19:47:40 -0700 Subject: [Tutor] a db question Message-ID: <200106110244.WAA11500@barry.mail.mindspring.net> Hi all, I'm new to Python. I love Python, and recently tried using it to do a very simple database project, but perhaps my expectations were unrealistic. Using Python 2.0 on a Win2000 machine with 256M Ram and many gigs of disk space, I couldn't successfully load a text file which consists of a 12 character key and a 38 character text string as the record. The problem is that the file consist of about 800,000 records. I used "anydb" which on my machine uses bsddb as the default (I believe). After about 120,000 records the load would halt with an "error: (0, 'error')" . The key and text string are normal. I can start the reload a couple of records short of where it blew up, and it continues for another 100,000 or so records, and blows up again, until it finally halts at about 400,000 records with a hard halt (invoking my Visual C++ debugger). I built in a file.sync instruction which happens every 10,000 records, and this didn't help. I suspect that I am asking the "db" routines to do too much, but that is disappointing to me, because Python has always done whatever I wanted in my limited past with it. Below is the very simple program that doesn't finish. Thanks for any advice!!! import os, anydbm ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c") ifile = open("e:\\python20\\lib\\wncdet","rb") fin = ifile.fileno() for x in range(0,783284): if x % 10000 == 0: ofile.sync print x ptr = os.lseek(fin,x * 50, 0) wstr = os.read(fin,50) if len(wstr) == 50: key12 = str(wstr[:12]) item = str(wstr[12:]) ofile[key12] = item os.close(fin) print "Done..." dum = raw_input("any key") ofile.clo From wheelege@tsn.cc Mon Jun 11 05:39:53 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Mon, 11 Jun 2001 14:39:53 +1000 Subject: [Tutor] a db question References: <200106110244.WAA11500@barry.mail.mindspring.net> Message-ID: <00cc01c0f230$907f7cc0$0200a8c0@ACE> > <...> > I built in a file.sync instruction which happens every 10,000 > records, and this didn't help. > I'm no db expert, but in your code you aren't calling that function - you have forgotten the ()'s :). > <...> > > import os, anydbm > ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c") > ifile = open("e:\\python20\\lib\\wncdet","rb") > fin = ifile.fileno() > for x in range(0,783284): > if x % 10000 == 0: > ofile.sync Just here ------^^ > print x Perhaps you could try your code without this print? > ptr = os.lseek(fin,x * 50, 0) > wstr = os.read(fin,50) > if len(wstr) == 50: > key12 = str(wstr[:12]) > item = str(wstr[12:]) > ofile[key12] = item > os.close(fin) > print "Done..." > dum = raw_input("any key") > ofile.clo And I assume this is a classic copy and paste error, but this should be ofile.close() :) Anywho, hope that helped, Glen. From wheelege@tsn.cc Mon Jun 11 07:52:23 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Mon, 11 Jun 2001 16:52:23 +1000 Subject: [Tutor] a db question References: <200106110535.BAA13343@maynard.mail.mindspring.net> Message-ID: <001201c0f243$1221a7a0$0200a8c0@ACE> > Glen, > > I tried your suggestions, putting the parentheses after "sync" and > getting rid of the print statement... it didn't help. It went much > faster with no print statement, but it blew up at exactly the same > spot. I carefully checked both the key value and the record (text > string), and they were fine. I think it may be that I only have 256M > of RAM, and I'm getting some kind of caching problem. Indeed, like some sort of virtual memory problem...good old windows. > Also, if I restart the program a couple of records before the one that > it blew up on, it continues fine for another 100,000 records or so, > so it doesn't seem to be a problem with my data. > That's good news. In that case, I would suggest using multiple files - your code looks like this... import os, anydbm ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c") ifile = open("e:\\python20\\lib\\wncdet","rb") fin = ifile.fileno() for x in range(0,783284): if x % 10000 == 0: ofile.sync print x ptr = os.lseek(fin,x * 50, 0) wstr = os.read(fin,50) if len(wstr) == 50: key12 = str(wstr[:12]) item = str(wstr[12:]) ofile[key12] = item os.close(fin) print "Done..." dum = raw_input("any key") ofile.close() Right? I suppose you could try doing the same thing, but split it up into smaller loops. For example... t = 0 for x in range(1000): t += x Could become... t = 0 for y in range((1000/10), (1000+(1000/10)), (1000/10)): ## that last thing is called the 'step' st = 0 for x in range((y-(1000/10)), y): st += x t += st del st I left the range things unsimplified because although the look a little ugly now, I hope that this way it is easier to see what is happening. In both cases t will have the same end value. Or, even better, look into the os() module and try to find stuff on memory allocation. I'm afraid that the multiple loops thing may just be a dead end, so it looks like either you get thrown a bone from people more knowledgeable than me (come on guys :) or have a bit of reading ahead of you. Either way, alot of fun. Hope that helped, Glen. From ppathiyi@cisco.com Mon Jun 11 10:50:33 2001 From: ppathiyi@cisco.com (Praveen Pathiyil) Date: Mon, 11 Jun 2001 15:20:33 +0530 Subject: [Tutor] Getting a function name from within itself Message-ID: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc> This is a multi-part message in MIME format. ------=_NextPart_000_00A3_01C0F28A.0EA2C1D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I am posting a question which is not specific to python.=20 Is there a way to get the name of a function from within itself = at runtime ? Suppose that i have a function f1. At the run time when it = encounters some condition ( errors or some condition which i want to let = the user know by printing), I want to say that this warning originated = from this function f1, without actually hard coding that name in the = print statement. def f1(self): --- do something -- Print "Warning ......", function_name Can i get the function name from execution environment or something ? Thanks, Praveen. ------=_NextPart_000_00A3_01C0F28A.0EA2C1D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all,
 
        I = am posting=20 a question which is not specific to python.
        Is there=20 a way to get the name of a function from within itself at runtime ? = Suppose that=20 i have a function f1. At the run time when it encounters some condition = ( errors=20 or some condition which i want to let the user know by printing), I want = to say=20 that this warning originated from this function f1, without actually = hard coding=20 that name in the print statement.
 
def f1(self):
    --- do something = --
    Print "Warning = ......",=20 function_name
 
Can i get the function name from = execution=20 environment or something ?
 
Thanks,
Praveen.
 
 
------=_NextPart_000_00A3_01C0F28A.0EA2C1D0-- From toodles@yifan.net Mon Jun 11 11:42:36 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Mon, 11 Jun 2001 18:42:36 +0800 Subject: [Tutor] Getting a function name from within itself In-Reply-To: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc> Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_0002_01C0F2A6.48A15740 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: base64 DQogICAgICAgICAgSSBhbSBwb3N0aW5nIGEgcXVlc3Rpb24gd2hpY2ggaXMgbm90IHNwZWNpZm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ogIHNpemU9Mj48L0ZPTlQ+PC9TUEFOPiZuYnNwOzwvRElWPg0KICA8RElW PjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0j MDAwMGZmIA0KICBzaXplPTI+Q2xhc3NlcyBhcmUgYWx3YXlzIGZ1biAqZ3Jpbio8L0ZPTlQ+PC9T UEFOPjwvRElWPg0KICA8RElWPjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBm YWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIA0KICBzaXplPTI+PC9GT05UPjwvU1BBTj4mbmJzcDs8 L0RJVj4NCiAgPERJVj48U1BBTiBjbGFzcz03MTAwNzIyMTAtMTEwNjIwMDE+PEZPTlQgZmFjZT1U YWhvbWEgY29sb3I9IzAwMDBmZiANCiAgc2l6ZT0yPkFuZHJldzwvRk9OVD48L1NQQU4+PC9ESVY+ PC9CTE9DS1FVT1RFPjwvQk9EWT48L0hUTUw+DQo= ------=_NextPart_000_0002_01C0F2A6.48A15740-- From arcege@speakeasy.net Mon Jun 11 13:07:43 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Mon, 11 Jun 2001 08:07:43 -0400 (EDT) Subject: [Tutor] Getting a function name from within itself In-Reply-To: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc> from "Praveen Pathiyil" at Jun 11, 2001 03:20:33 PM Message-ID: <200106111207.f5BC7he11666@dsl092-074-184.bos1.dsl.speakeasy.net> Praveen Pathiyil wrote > I am posting a question which is not specific to python.=20 > Is there a way to get the name of a function from within itself = > at runtime ? Suppose that i have a function f1. At the run time when it = > encounters some condition ( errors or some condition which i want to let = > the user know by printing), I want to say that this warning originated = > from this function f1, without actually hard coding that name in the = > print statement. > > def f1(self): > --- do something -- > Print "Warning ......", function_name > > Can i get the function name from execution environment or something ? You can use the traceback object from exceptions to get this information. >>> def get_caller(): ... import sys ... try: raise SystemError ... except SystemError: ... exc, val, tb = sys.exc_info() ... # from the traceback, get the second frame back (first is get_caller) ... caller = tb.tb_frame.f_back ... # delete the traceback object to free memory ... del exc, val, tb ... return caller ... At this point, you would get a frame for the calling function, which contain a reference to the code, and subsequently to the name. >>> def whatsmyline(): ... print 'function name is', get_caller().f_code.co_name ... >>> whatsmyline() function name is whatsmyline >>> This is the most common (and least obtrusive) idiom. In Python 2.1, there is now a new standard library module called "inspect" which does a lot of this for you. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From hanna@chagford.com Mon Jun 11 22:40:49 2001 From: hanna@chagford.com (Hanna Joo) Date: Mon, 11 Jun 2001 14:40:49 -0700 Subject: [Tutor] Threads.. help /___\ (look of despair) Message-ID: <012001c0f2bf$303aa940$0100007f@localdomain> Hi all I wrote a simple consumer - producer program trying to use threads (solid emphasis on 'trying'). I have this feeling I don't know how to pass arguments to threads and keep it synchronized.. any help will be greatly appreaciated. import threading from time import sleep def producer(): soup = 'ABCDEFGHIJKLMNOP' while len(buff) != 15: inx = randint(1,15) buff.append(soup[inx]) print soup[inx], "thrown into soup!!" sleep(randint(1,3)) def consumer(): while len(buff) : a = buff.pop() print a, "eaten from soup!!" sleep(randint(1,3)) def main(): print 'starting threads...' buff = [] firstthread = threading.Thread(target=producer, args=(buffer)) #----> problem area!! secondthread = threading.Thread(target=consumer, args=(buffer)) #----> problem area!! firstthread.start() secondthread.start() firstthread.join() secondthread.join() if __name__ == '__main__': main() ERROR>: Exception in thread Thread-1: Traceback (most recent call last): File "c:\python\lib\threading.py", line 376, in __bootstrap self.run() File "c:\python\lib\threading.py", line 364, in run apply(self.__target, self.__args, self.__kwargs) TypeError: apply() 2nd argument must be a sequence Exception in thread Thread-2: Traceback (most recent call last): File "c:\python\lib\threading.py", line 376, in __bootstrap self.run() File "c:\python\lib\threading.py", line 364, in run apply(self.__target, self.__args, self.__kwargs) TypeError: apply() 2nd argument must be a sequence TIA Hanna From arcege@speakeasy.net Mon Jun 11 14:46:10 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Mon, 11 Jun 2001 09:46:10 -0400 (EDT) Subject: [Tutor] Threads.. help /___\ (look of despair) In-Reply-To: <012001c0f2bf$303aa940$0100007f@localdomain> from "Hanna Joo" at Jun 11, 2001 02:40:49 PM Message-ID: <200106111346.f5BDkAo11794@dsl092-074-184.bos1.dsl.speakeasy.net> Hanna Joo wrote > > Hi all > > I wrote a simple consumer - producer program trying to use threads (solid > emphasis on 'trying'). I have this feeling I don't know how to pass > arguments to threads and keep it synchronized.. any help will be greatly > appreaciated. I see four errors here: 1. You are not importing the randint function. This is minor though. from random import randint 2. The arguments to the threads should be a sequence (really should be a tuple); to make a singleton tuple, you need to add a comma: (1) ==> the expression of the number 1 (1,) ==> a tuple containing the number 1 3. Both functions do not allow for the argument being given. def producer(buff): 4. The "buffer" in main does not exist, but "buff" does. You should be consistant in the names within a function. > import threading > from time import sleep from random import randint > > def producer(): def producer(buff): > > soup = 'ABCDEFGHIJKLMNOP' > while len(buff) != 15: > inx = randint(1,15) > buff.append(soup[inx]) > print soup[inx], "thrown into soup!!" > sleep(randint(1,3)) > > def consumer(): def consumer(buff): > > while len(buff) : > a = buff.pop() > print a, "eaten from soup!!" > sleep(randint(1,3)) > > > def main(): > > print 'starting threads...' > buff = [] buffer = [] > firstthread = threading.Thread(target=producer, args=(buffer)) firstthread = threading.Thread(target=producer, args=(buffer,)) > secondthread = threading.Thread(target=consumer, args=(buffer)) secondthread = threading.Thread(target=consumer, args=(buffer,)) > > firstthread.start() > secondthread.start() > > firstthread.join() > secondthread.join() > > if __name__ == '__main__': > main() Once I made these changes, I got a working program (but probably not what is expected *smile*). HTH :) -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From dyoo@hkn.eecs.berkeley.edu Mon Jun 11 16:53:49 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 11 Jun 2001 08:53:49 -0700 (PDT) Subject: [Tutor] Getting a function name from within itself In-Reply-To: Message-ID: On Mon, 11 Jun 2001, Andrew Wilkins wrote: > I am posting a question which is not specific to python. > Is there a way to get the name of a function from within > itself at runtime ? Suppose that i have a function f1. At the run time > when it encounters some condition ( errors or some condition which i > want to let the user know by printing), I want to say that this > warning originated from this function f1, without actually hard coding > that name in the print statement. There must be a way to do this in Python, because the following: ### >>> def f(): ... pass ... >>> x = f >>> x ### shows that 'x' remembers that it actually came out of function f. So, if anything, we can always ask for the string repr() of a function during runtime. After that, we can pull the name out of the string. But this seems like a lot of work. Michael's suggestion to use inspect sounds like the best way to get the function's name, but I've actually never used inspect. Well, it's a good time to learn now! *grin* Let's see... http://python.org/doc/current/lib/inspect-types.html sounds about right. It appears to show that we can use inspect.getmembers(), and then pull out the particular 'member' that contains the name: ### >>> import inspect >>> inspect.getmembers(x) [('__dict__', None), ('__doc__', None), ('__name__', 'f'), ('func_closure', None), ('func_code', ", line 1>), ('func_defaults', None), ('func_dict', None), ('func_doc', None), ('func_globals', {'__doc__': None, 'inspect': , 'x': , 'i': 25, 'f': , '__builtins__': , '__name__': '__main__'}), ('func_name', 'f')] ### Hmmm... that's a little ugly; we just want the one associated with the func_name; that appears to be the last record: ### >>> inspect.getmembers(x)[-1] ('func_name', 'f') >>> inspect.getmembers(x)[-1][-1] 'f' ### Ah! But it's unreasonable to have to always type that to get the name. Let's make this into a function, so we don't have to do so much indicing: ### >>> def getFuncName(f): return inspect.getmembers(f)[-1][-1] ... >>> getFuncName(x) 'f' ### Ok, this appears to work for this case. I wonder what happens with functions with no name at all... ### >>> getFuncName(lambda x: 1) '' ### I haven't fully tested this code yet, but it seems something you can play with as well. Hope this helps! From bill-bell@bill-bell.hamilton.on.ca Mon Jun 11 17:29:55 2001 From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 11 Jun 2001 12:29:55 -0400 Subject: [Tutor] RE: Getting a function name from within itself In-Reply-To: Message-ID: <3B24B9C3.1554.DA3F463@localhost> > On Mon, 11 Jun 2001, Andrew Wilkins wrote: > I am posting a question which is not specific to python. Is there a > way to get the name of a function from within itself at runtime ? > Suppose that i have a function f1. At the run time when it > encounters some condition ( errors or some condition which i want > to let the user know by printing), I want to say that this warning > originated from this function f1, without actually hard coding that > name in the print statement. Although your question is not specific to Python solutions are, in general, specific to each language and sometimes to each language's implementation. A recipe is available for Python on the Activestate site. http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52315 For Perl, as another example, see Recipe 10.4 in "Perl Cookbook" (Christiansen and Torkington), "Determining Current Function Name". Bill Bill Bell, Software Developer From deirdre@deirdre.net Mon Jun 11 18:26:10 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 11 Jun 2001 10:26:10 -0700 Subject: [Tutor] Threads.. help /___\ (look of despair) In-Reply-To: <012001c0f2bf$303aa940$0100007f@localdomain> References: <012001c0f2bf$303aa940$0100007f@localdomain> Message-ID: >I wrote a simple consumer - producer program trying to use threads (solid >emphasis on 'trying'). I have this feeling I don't know how to pass >arguments to threads and keep it synchronized.. any help will be greatly >appreaciated. Synchronization between threads is one of the trickiest problems with the most subtle consequnces of any problem in computer science. Even very experienced programmers have problems with it. But your basic synchronization problem is simply not using the features of threads: locking and unlocking. My suggestion would be to learn the concepts of threading with a lower-level interface (i.e. import thread) and mutexes and semaphores THEN move to the higher level interface. There's an excellent series of articles (applicable to python on Windows as much as anything) in Linux magazine that is a very good thread primer. I'm not sure when the article series started, but I have the March issue in hand. -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From allan.crooks@btinternet.com Mon Jun 11 19:29:03 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Mon, 11 Jun 2001 19:29:03 +0100 Subject: [Tutor] Buffer's? Message-ID: Can anyone explain to me what the buffer function actually does? I can't find much mention about it in the Python documentation..... From DOUGS@oceanic.com Mon Jun 11 19:42:06 2001 From: DOUGS@oceanic.com (Doug Stanfield) Date: Mon, 11 Jun 2001 08:42:06 -1000 Subject: [Tutor] a db question Message-ID: <8457258D741DD411BD3D0050DA62365907A8A5@huina.oceanic.com> [William N Carey asked:] > I couldn't successfully load a text file which consists of a 12 > character key and a 38 character text string as the record. The > problem is that the file consist of about 800,000 records. I > used "anydb" which on my machine uses bsddb as the default (I > believe). After about 120,000 records the load would halt with > an "error: (0, 'error')" I have had similar experiences with the db files on Windows. I know others have also because there are alternatives to the standard bsddb. I gave up on the platform and moved to Linux where everything worked great, but if you can't do that there may be other solutions. > I suspect that I am asking the "db" routines to do too much, but > that is disappointing to me, because Python has always done > whatever I wanted in my limited past with it. Don't blame it on Python! The blame lies elsewhere. One fix might be a different database type; I've heard good things about Gadfly and Metakit. Check out the database page at the Vaults of Parnassus: http://www.vex.net/parnassus/apyllo.py/973100124 HTH -Doug- From jarrett@engineer.com Mon Jun 11 19:56:24 2001 From: jarrett@engineer.com (W. Jarrett Campbell) Date: Mon, 11 Jun 2001 13:56:24 -0500 Subject: [Tutor] basic gadfly question Message-ID: I'm new to the world of Python, Databases, and SQL but it has been a fun adventure so far! What a great resource this tutor mailing list is. Thank you all for your support of newbies! I have basic question regarding the Gadfly package. I'm working with the sample database generated by the gftest.py module. I'm trying to execute an SQL statement such as: INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') When I do this I get an error back saying that I did not define a value for the column 'PERWEEK' My questions are these? Do you have to set all values in the insert statement or is there some way around this? Is this bad database programming form to want to set only some fields? Is this related to gadfly not supporting Null values? When using the ODBC package in the win32all distribution, I can achieve this functionality with MS Access databases. I wanted to stick with gadfly to remain platform independent and not require my users to purchase Access. Any advice? Thanks in advance, W. Jarrett Campbell jarrett@engineer.com From rha207@worldnet.att.net Mon Jun 11 19:55:58 2001 From: rha207@worldnet.att.net (Ron) Date: Mon, 11 Jun 2001 14:55:58 -0400 Subject: [Tutor] def problem Message-ID: <000801c0f2a8$275e68a0$0f7c4c0c@computer> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0F286.9F729540 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm having problems with "def". Here's what I put in and save as = "test122" def here(): print "hello" print print "that was a space" This is what I get. >>> import test123 >>> here() Traceback (most recent call last): File "", line 1, in ? here() NameError: name 'here' is not defined >>>=20 ------=_NextPart_000_0005_01C0F286.9F729540 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I'm having problems with "def". Here's = what I put=20 in and save as "test122"
 
def here():
    print = "hello"
    print
    print "that = was a=20 space"
 
This is what I get.
 
>>> import = test123
>>>=20 here()
Traceback (most recent call last):
  File = "<pyshell#1>",=20 line 1, in ?
    here()
NameError: name 'here' is = not=20 defined
>>>
------=_NextPart_000_0005_01C0F286.9F729540-- From deirdre@deirdre.net Mon Jun 11 20:04:32 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 11 Jun 2001 12:04:32 -0700 Subject: [Tutor] basic gadfly question In-Reply-To: References: Message-ID: At 1:56 PM -0500 6/11/01, W. Jarrett Campbell wrote: >I have basic question regarding the Gadfly package. I'm working with the >sample database generated by the gftest.py module. I'm trying to execute an >SQL statement such as: > >INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') > >When I do this I get an error back saying that I did not define a value for >the column 'PERWEEK' > >My questions are these? Do you have to set all values in the insert >statement or is there some way around this? Gadfly requires this. It is not a constraint of SQL generally. >Is this bad database >programming form to want to set only some fields? Is this related to gadfly >not supporting Null values? No, but since it doesn't support nulls, that's a design compromise. >When using the ODBC package in the win32all distribution, I can achieve this >functionality with MS Access databases. I wanted to stick with gadfly to >remain platform independent and not require my users to purchase Access. >Any advice? There are also other cross-platform databases that don't require licenses (mysql, postgres, berkeleydb). I know nothing about their support on Windows but use the first two on Linux. But none are as simple to set up as gadfly. Gadfly is quirky, but if it suits your needs, it's great. -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From kalle@gnupung.net Mon Jun 11 20:12:43 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Mon, 11 Jun 2001 21:12:43 +0200 Subject: [Tutor] def problem In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer>; from rha207@worldnet.att.net on Mon, Jun 11, 2001 at 02:55:58PM -0400 References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> Message-ID: <20010611211243.B5198@father> Sez Ron: > I'm having problems with "def". Here's what I put in and save as "test122" > > def here(): > print "hello" > print > print "that was a space" > > This is what I get. > > >>> import test123 > >>> here() > Traceback (most recent call last): > File "", line 1, in ? > here() > NameError: name 'here' is not defined > >>> This is not a problem with def, just a misunderstanding of import. You have to access the names of the test123 module like: >>> import test123 >>> test123.here() hello that was a space >>> You could also use the "from x import y" statement: >>> from test123 import here >>> here() hello that was a space >>> Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From bdupire@seatech.fau.edu Mon Jun 11 20:15:07 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Mon, 11 Jun 2001 15:15:07 -0400 Subject: [Tutor] def problem References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> Message-ID: <3B2518BA.9078857D@seatech.fau.edu> --------------E3E5CA49B2922E202ECD33F7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ron wrote: > I'm having problems with "def". Here's what I put in and save as > "test122" def here(): > print "hello" > print > print "that was a space" This is what I get. >>> import test123 > >>> here() > Traceback (most recent call last): > File "", line 1, in ? > here() > NameError: name 'here' is not defined > >>> This is because the function called here() does not exist in the current namespace. here() lives in the module namespace (test123) Thus, to call the function, you must prefix it with the name of the module. It becomes: test123.here() -- Benoit Dupire --------------E3E5CA49B2922E202ECD33F7 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit  

Ron wrote:

I'm having problems with "def". Here's what I put in and save as "test122" def here():
    print "hello"
    print
    print "that was a space" This is what I get. >>> import test123
>>> here()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    here()
NameError: name 'here' is not defined
>>>

This is because the function called here() does not exist in the current namespace.
here() lives in the module namespace (test123)
Thus, to call the function, you must prefix it with the name of the module.
It becomes:

test123.here()
 

--
Benoit Dupire
  --------------E3E5CA49B2922E202ECD33F7-- From pobrien@orbtech.com Mon Jun 11 20:18:50 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Mon, 11 Jun 2001 14:18:50 -0500 Subject: [Tutor] def problem In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer> Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_001A_01C0F281.6FE2A040 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit The secret is in namespaces, which is basically a way of controlling what is visible at any given point in time. One way to know what is visible is the dir() function. Try running dir() after you do your import and you will see test123 listed, but not here(). That means python can’t “see” here() without a little more help from you. If you then try dir(test123) you will see here() listed. So here() is part of test123. That means test123.here() will work while here() by itself will not. Does that make sense? Now, if you really want to be able to just type here() and have python understand what you mean, you must import thusly: from test123 import here Once you get the hang of it you will come to love namespaces. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Ron Sent: Monday, June 11, 2001 1:56 PM To: tutor@python.org Subject: [Tutor] def problem I'm having problems with "def". Here's what I put in and save as "test122" def here(): print "hello" print print "that was a space" This is what I get. >>> import test123 >>> here() Traceback (most recent call last): File "", line 1, in ? here() NameError: name 'here' is not defined >>> ------=_NextPart_000_001A_01C0F281.6FE2A040 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Th= e secret is in namespaces, which is basically a way of controlling what is = visible at any given point in time. One way to know what is visible is the dir() = function. Try running dir() after you do your import and you will see test123 = listed, but not here(). That means python can’t “see” here() = without a little more help from you. If you then try dir(test123) you will see here() listed. So = here() is part of test123. That means test123.here() will work while here() by = itself will not. Does that make sense?

 

No= w, if you really want to be able to just type here() and have python = understand what you mean, you must import thusly:

 

fr= om test123 import here

 

On= ce you get the hang of it you will come to love = namespaces.

 

---

Patrick = K. O'Brien

Orbtech=

"I = am, therefore I think."

<= span class=3DEmailStyle15> 

-----Original Message-----
From: = tutor-admin@python.org [mailto:tutor-admin@python.org]On = Behalf Of Ron
Sent: Monday, June 11, = 2001 1:56 PM
To: tutor@python.org
Subject: [Tutor] def = problem

 

I'm having problems with = "def". Here's what I put in and save as "test122"<= /p>

 <= /p>

def here():
    print "hello"
    print
    print "that was a space"
<= /p>

 <= /p>

This is what I = get.<= /p>

 <= /p>

>>> import test123
>>> here()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    here()
NameError: name 'here' is not defined
>>>

------=_NextPart_000_001A_01C0F281.6FE2A040-- From lumbricus@gmx.net Mon Jun 11 20:21:38 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Mon, 11 Jun 2001 21:21:38 +0200 Subject: [Tutor] def problem In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer>; from rha207@worldnet.att.net on Mon, Jun 11, 2001 at 02:55:58PM -0400 References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> Message-ID: <20010611212138.A15875@Laplace.localdomain> On Mon, Jun 11, 2001 at 02:55:58PM -0400, Ron wrote: > I'm having problems with "def". Here's what I put in and save as "test122" > > def here(): > print "hello" > print > print "that was a space" > > This is what I get. > > >>> import test123 > >>> here() >>> test123.here() HTH J! -- If you laid all of our laws end to end, there would be no end. -- Mark Twain From glingl@aon.at Mon Jun 11 20:26:05 2001 From: glingl@aon.at (Gregor Lingl) Date: Mon, 11 Jun 2001 21:26:05 +0200 Subject: [Tutor] def problem References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> Message-ID: <3B251B4D.20716326@aon.at> --------------8BBF5159477132DCF7019982 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ron schrieb: > I'm having problems with "def". Here's what I put in and save as > "test122" def here(): > print "hello" > print > print "that was a space" This is what I get. >>> import test123 > >>> here() > Traceback (most recent call last): > File "", line 1, in ? > here() > NameError: name 'here' is not defined > >>> you have to call (qualified): >>> test123.here() hello that was a space >>> or to import this way: >>> from test123 import * >>> here() hello that was a space >>> Gregor --------------8BBF5159477132DCF7019982 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit  

Ron schrieb:

I'm having problems with "def". Here's what I put in and save as "test122" def here():
    print "hello"
    print
    print "that was a space" This is what I get. >>> import test123
>>> here()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    here()
NameError: name 'here' is not defined
>>>


you have to call (qualified):

>>> test123.here()
hello

that was a space
>>>

or to import this way:
>>> from test123 import *
>>> here()
hello

that was a space
>>>

Gregor --------------8BBF5159477132DCF7019982-- From allan.crooks@btinternet.com Mon Jun 11 20:22:54 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Mon, 11 Jun 2001 20:22:54 +0100 Subject: [Tutor] Central Python Library / Viewing __doc__ strings Message-ID: [Denesting program] > Ah, yes. That code sounds interesting. I wouldn't mind seeing it myself. I > think I might have a need for something like that, actually. You asked for it. :) It's called fringe because I had to create a similar function in Scheme for my course at university, and that's the name we had to call it. Maybe it's suitable, I don't know. :) The code is at the end of the message. > Useless Python > is a great spot for something like this and the Python Cookbook is as well > (http://aspn.activestate.com/ASPN/Python/Cookbook/). I think the Python > Cookbook is exactly what you were looking for. See what you think. In the > mean time, I'd love a copy of the code. Thanks. Thanks for the links, I'm off to waste an entire night looking at it. :) Allan. ---------- def isList(obj): """isList(obj) -> Returns true if obj is a Python list. This function does not return true if the object supplied is a UserList object. """ return type(obj)==types.ListType def isTuple(obj): "isTuple(obj) -> Returns true if obj is a Python tuple." return type(obj)==types.TupleType def isPySeq(obj): """isPySeq(obj) -> Returns true if obj is a Python list or a Python tuple. This function does not return true if the object supplied is a UserList object. """ return isList(obj) or isTuple(obj) def isLongString(obj): """isLongString(obj) -> Returns true if obj is a string of a size larger than 1. This function does not return true if the object supplied is a UserString object. """ return type(obj)==types.StringType and len(obj)>1 # I like how the doc for this dwarfs the size of the code. :) def fringe (seq, func=isPySeq): """fringe(seq [,func]) -> Denests a sequence (seq). A list is returned which contains all elements in the sequence. If the sequence contains other sequences, then the elements inside it are added to the list that is returned, as opposed to adding the nested sequence to the list. By default, if the sequence contains any lists or tuples, they are denested. Other sequence types (such as strings) are not. If you wish to alter the behaviour of this, then you must supply a function, which will be called with one argument (an element). The function must return a boolean object to indicate if the object is a sequence, and thus requires de-nesting. Care needs to be taken if a function is supplied that regards a string as a sequence. Each element in a string is also a string of size 1, meaning that for any function which returns true if the object is a non-empty string will recurse infinitely. If you wish to decompose strings, you should create a function which uses the isLongString method in this module. It should be noted that this method will crash if the sequence contains circular references to itself. """ res = [] for x in seq: __fringe(x, func, res) return res def __fringe (obj, func, res): "Helper method for fringe." if func(obj): for x in obj: __fringe (x, func, res) else: res.append(obj) From cynic@mail.cz Mon Jun 11 20:37:12 2001 From: cynic@mail.cz (Cynic) Date: Mon, 11 Jun 2001 21:37:12 +0200 Subject: [Tutor] basic gadfly question In-Reply-To: References: Message-ID: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> At 21:04 11.6. 2001, Deirdre Saoirse Moen wrote the following: -------------------------------------------------------------- >At 1:56 PM -0500 6/11/01, W. Jarrett Campbell wrote: >>I have basic question regarding the Gadfly package. I'm working with the >>sample database generated by the gftest.py module. I'm trying to execute an >>SQL statement such as: >> >>INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') >> >>When I do this I get an error back saying that I did not define a value for >>the column 'PERWEEK' >> >>My questions are these? Do you have to set all values in the insert >>statement or is there some way around this? > >Gadfly requires this. It is not a constraint of SQL generally. > >>Is this bad database >>programming form to want to set only some fields? Is this related to gadfly >>not supporting Null values? NULL values are BAD. Learn about SQL, and you'll understand why. >No, but since it doesn't support nulls, that's a design compromise. > >>When using the ODBC package in the win32all distribution, I can achieve this >>functionality with MS Access databases. I wanted to stick with gadfly to >>remain platform independent and not require my users to purchase Access. >>Any advice? > >There are also other cross-platform databases that don't require licenses (mysql, postgres, berkeleydb). I know nothing about their support on Windows but use the first two on Linux. win32 MySQL is great. easy to setup -- just a regular windows installer. also, the support is good. postgres, on the other hand, was a bitch to get running (on windows), at least when I tried, which was almost two years ago. :) and, the mailing lists supposedly provide less help. >But none are as simple to set up as gadfly. I have never heard of that, let alone use it, so I do know. >Gadfly is quirky, but if it suits your needs, it's great. >-- >_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net >"Cannot run out of time.... Is infinite time. You... are finite.... >Zathrus... is finite. This... is wrong tool!" -- Zathrus > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor ------end of quote------ cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7 From deirdre@deirdre.net Mon Jun 11 20:45:52 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 11 Jun 2001 12:45:52 -0700 Subject: [Tutor] basic gadfly question In-Reply-To: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> Message-ID: At 9:37 PM +0200 6/11/01, Cynic wrote: > >>My questions are these? Do you have to set all values in the insert >>>statement or is there some way around this? >> >>Gadfly requires this. It is not a constraint of SQL generally. >> >>>Is this bad database >>>programming form to want to set only some fields? Is this related to gadfly >>>not supporting Null values? > >NULL values are BAD. Learn about SQL, and you'll understand why. This is *completely* untrue. In fact, if you actually READ Codd & Date, you'll discover why supporting null values is a requirement for a truly relational database. Why? Because sometimes there isn't a relationship between a record in one entity and another entity. And sometimes there is. For example, a student relation may have a link to a faculty relation only if the student has an advisor. If that student doesn't have an advisor, that attribute SHOULD be null. In a truly relational database, the null value would signify there was no relationship, which is correct. If you don't support nulls, you'd have to create a false value to a false record in the other relation, which implies a relationship that doesn't in fact exist. > >But none are as simple to set up as gadfly. > >I have never heard of that, let alone use it, so I do know. Gadfly is a SQL implementation written entirely in Python and can be found at http://www.chordate.com -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From kalle@gnupung.net Mon Jun 11 20:53:47 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Mon, 11 Jun 2001 21:53:47 +0200 Subject: [Tutor] def problem In-Reply-To: <3B251B4D.20716326@aon.at>; from glingl@aon.at on Mon, Jun 11, 2001 at 09:26:05PM +0200 References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> <3B251B4D.20716326@aon.at> Message-ID: <20010611215347.B5451@father> Sez Gregor Lingl: [snip] > or to import this way: > >>> from test123 import * I would recommend against using "from x import *", use "from x import w,y,z" instead. "from x import *" might rebind names in the current namespace that you do not want it to... Sure, there are specail cases (Tkinter leaps to mind) where there are no such problems, but better safe than sorry. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From cynic@mail.cz Mon Jun 11 21:32:18 2001 From: cynic@mail.cz (Cynic) Date: Mon, 11 Jun 2001 22:32:18 +0200 Subject: [Tutor] basic gadfly question In-Reply-To: References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> Message-ID: <5.1.0.14.2.20010611221822.00baf3c8@mail.cz> >A relation is in third normal form (3NF) if and only if it is >in 2NF and every nonkey attribute is nontransitively dependent >on the primary key. So, as you can see, NULLs actually break normalization rules. At 21:45 11.6. 2001, Deirdre Saoirse Moen wrote the following: -------------------------------------------------------------- >This is *completely* untrue. > >In fact, if you actually READ Codd & Date, you'll discover why supporting null values is a requirement for a truly relational database. > >Why? Because sometimes there isn't a relationship between a record in one entity and another entity. And sometimes there is. > >For example, a student relation may have a link to a faculty relation only if the student has an advisor. If that student doesn't have an advisor, that attribute SHOULD be null. > >In a truly relational database, the null value would signify there was no relationship, which is correct. > >If you don't support nulls, you'd have to create a false value to a false record in the other relation, which implies a relationship that doesn't in fact exist. ------end of quote------ cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7 From clickron@webtv.net Mon Jun 11 21:28:07 2001 From: clickron@webtv.net (Ron) Date: Mon, 11 Jun 2001 16:28:07 -0400 (EDT) Subject: [Tutor] Re: def problem (Thanks) In-Reply-To: tutor-request@python.org's message of Mon, 11 Jun 2001 15:19:02 -0400 Message-ID: <13511-3B2529D7-1702@storefull-166.iap.bryant.webtv.net> Sometimes you just don't see the forest for the trees. Appreciate the help everybody. Thanks. Ron From deirdre@deirdre.net Mon Jun 11 21:33:20 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 11 Jun 2001 13:33:20 -0700 Subject: [Tutor] basic gadfly question In-Reply-To: <5.1.0.14.2.20010611221822.00baf3c8@mail.cz> References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> <5.1.0.14.2.20010611221822.00baf3c8@mail.cz> Message-ID: At 10:32 PM +0200 6/11/01, Cynic wrote: > >A relation is in third normal form (3NF) if and only if it is >>in 2NF and every nonkey attribute is nontransitively dependent >>on the primary key. > >So, as you can see, NULLs actually break normalization rules. No, because a null value isn't transitively dependent upon the primary key. Or do you not understand transitive dependencies? -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From pobrien@orbtech.com Mon Jun 11 21:59:40 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Mon, 11 Jun 2001 15:59:40 -0500 Subject: [Tutor] Re: def problem (Thanks) In-Reply-To: <13511-3B2529D7-1702@storefull-166.iap.bryant.webtv.net> Message-ID: And then a dozen lumberjacks come scrambling out of the woods all offering to help you chop down your sapling, right? --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Ron Sent: Monday, June 11, 2001 3:28 PM To: tutor@python.org Subject: [Tutor] Re: def problem (Thanks) Sometimes you just don't see the forest for the trees. Appreciate the help everybody. Thanks. Ron _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From DavidCraig@PIA.CA.GOV Mon Jun 11 22:45:55 2001 From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV) Date: Mon, 11 Jun 2001 14:45:55 -0700 Subject: [Tutor] What am I missing?? Message-ID: I am working through the python tutorial on "How to think like a Computer Scientist in Python". I know its simple but I can't find why this does not work. This is the distance() I have written. Below is the error message I get. # distance function def distance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = sqrt(dsquared) return result Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import math >>> distance(1, 2, 4, 6) Traceback (most recent call last): File "", line 1, in ? distance(1, 2, 4, 6) NameError: name 'distance' is not defined TIA for any assistance : )) Dave D. H. Craig, CSM From kromag@nsacom.net Tue Jun 12 01:04:49 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Mon, 11 Jun 2001 17:04:49 -0700 (PDT) Subject: [Tutor] Threads.... More Despair.... Message-ID: <200106120004.f5C04ng07464@pop.nsacom.net> I read of Hannah's plight with interest, as threads are kicking my backside as well. The following pathetic script attempts to summon up a thread, write to a database and exit: import win32com.client import random import time import string import thread engine=win32com.client.Dispatch("DAO.DBEngine.35") db=engine.OpenDatabase("\windows\desktop\terror.mdb") ## Function write() writes a list to the database def write(inputtage): time=inputtage[0] data_string=inputtage[1] db.Execute("insert into data values(%f, '%s')" %(time, data_string)) return 'ok' tik_tok=time.time() surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) the_madness=(tik_tok, surprize) thread.start_new_thread(write(the_madness)) gets this error: Traceback (most recent call last): File "dbwrite.py", line 21, in ? thread.start_new_thread(write(the_madness)) TypeError: start_new_thread requires at least 2 arguments; 1 given Fair enough. I looked again at my spanking new copy of "Python Standard Library" and noticed that in the example 'start_new_thread(worker, ())'. In the example, worker() does not accept an argument. Hrm. In the spirit of blind flailing I attempted: thread.start_new_thread(write(the_madness),()) and got: Traceback (most recent call last): File "dbwrite.py", line 21, in ? thread.start_new_thread(write(the_madness), ()) TypeError: first arg must be callable for my troubles. Since I don't have a clue what is going on this was not a big surprize! :-) Spawn seems so much easier! :-) d From kauphlyn@speakeasy.org Mon Jun 11 23:04:52 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Mon, 11 Jun 2001 15:04:52 -0700 (PDT) Subject: [Tutor] What am I missing?? In-Reply-To: Message-ID: well from the look of your interpriter session and the name error, it doesnt look like you defined the distance function in the the interpriter. try this: >> import math >> def distance(x1,y1,x2,y2): .. dx = x2 - x1 .. dy = y2 - y1 .. dsquared = dx**2 + dy**2 .. result = math.sqrt(dsquared) .. return result .. >>distance(1,2,3,4) 2.8284 etc >> On Mon, 11 Jun 2001, DavidCraig@PIA.CA.GOV wrote: > I am working through the python tutorial on "How to think like a Computer > Scientist in Python". > > I know its simple but I can't find why this does not work. This is the > distance() I have written. Below is the error message I get. > > # distance function > > def distance(x1, y1, x2, y2): > dx = x2 - x1 > dy = y2 - y1 > dsquared = dx**2 + dy**2 > result = sqrt(dsquared) > return result > > > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> import math > >>> distance(1, 2, 4, 6) > Traceback (most recent call last): > File "", line 1, in ? > distance(1, 2, 4, 6) > NameError: name 'distance' is not defined > > TIA for any assistance : )) > > Dave > > > > > D. H. Craig, CSM > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From ak@silmarill.org Mon Jun 11 23:08:13 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Mon, 11 Jun 2001 18:08:13 -0400 Subject: [Tutor] What am I missing?? In-Reply-To: <"from DavidCraig"@PIA.CA.GOV> References: Message-ID: <20010611180813.A8110@sill.silmarill.org> On Mon, Jun 11, 2001 at 02:45:55PM -0700, DavidCraig@PIA.CA.GOV wrote: > I am working through the python tutorial on "How to think like a Computer > Scientist in Python". > > I know its simple but I can't find why this does not work. This is the > distance() I have written. Below is the error message I get. > > # distance function > > def distance(x1, y1, x2, y2): > dx = x2 - x1 > dy = y2 - y1 > dsquared = dx**2 + dy**2 > result = sqrt(dsquared) > return result Where did you type this in? You have two choices that would both work: first, you can type it in a file, e.g. distfile.py, then start the interpreter, and do this: >>> from distfile import distance >>> import math >>> distance(1,2,4,6) OR you can type the function in the interpreter, like this: >>> def distance(x1,y1,x2,y2): >>> dx = x2 - x1 [...] and then use it this time without the need to import distance. > > > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> import math > >>> distance(1, 2, 4, 6) > Traceback (most recent call last): > File "", line 1, in ? > distance(1, 2, 4, 6) > NameError: name 'distance' is not defined > > TIA for any assistance : )) > > Dave > > > > > D. H. Craig, CSM > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- The point of philosophy is to start with something so simple as not to seem worth stating, and to end with something so paradoxical that no one will believe it. From deirdre@deirdre.net Mon Jun 11 23:13:44 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 11 Jun 2001 15:13:44 -0700 Subject: Normal Forms was Re: [Tutor] basic gadfly question In-Reply-To: References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> <5.1.0.14.2.20010611212548.00baf3c8@mail.cz> <5.1.0.14.2.20010611221822.00baf3c8@mail.cz> Message-ID: >At 10:32 PM +0200 6/11/01, Cynic wrote: >> >A relation is in third normal form (3NF) if and only if it is >>>in 2NF and every nonkey attribute is nontransitively dependent >>>on the primary key. >> >>So, as you can see, NULLs actually break normalization rules. > >No, because a null value isn't transitively dependent upon the >primary key. Or do you not understand transitive dependencies? Because this does come up: For a schema R, where A->BC, BC->CD D->E (the left side is the many side, the right side is the one side) A transitive dependency would be A->D or A->E or B->E. Because A->BC, therefore A->B and A->C. BC->CD, since C is the same on both sides, that means B->D, so, by transitivity rules, A -> B and B -> D, therefore A -> D. Note that B->D and D->B, which indicates a one-to-one relationship. In other words, it means that there's a compound join the schema, like so: order uniquely identifies which customer and which sales rep customer uniquely identifies zip code Now let's say that this order is one relation, and that relation is: order #, order date, customer number, customer name, customer company name, customer address, customer city, customer state, customer zip. This relation would not be in 3NF because customer company name is dependent upon customer number and NOT on the primary key for the relation (order #). The fact that the company name may or may not be a null value has nothing to do with being in 3NF or not. -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From DavidCraig@PIA.CA.GOV Mon Jun 11 23:16:57 2001 From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV) Date: Mon, 11 Jun 2001 15:16:57 -0700 Subject: [Tutor] def distance Message-ID: Thanks all for the help. Daniel, that works and makes much sense. Dave D. H. Craig, CSM From allan.crooks@btinternet.com Tue Jun 12 01:04:44 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Tue, 12 Jun 2001 01:04:44 +0100 Subject: [Tutor] Threads.... More Despair.... Message-ID: This'll be my first piece of help I've ever given anyone on this list! I'm doing my bit! :) > ## Function write() writes a list to the database > def write(inputtage): > time=inputtage[0] > data_string=inputtage[1] > db.Execute("insert into data values(%f, '%s')" %(time, data_string)) > return 'ok' > > tik_tok=time.time() > surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) > the_madness=(tik_tok, surprize) > thread.start_new_thread(write(the_madness)) > > gets this error: > > Traceback (most recent call last): > File "dbwrite.py", line 21, in ? > thread.start_new_thread(write(the_madness)) > TypeError: start_new_thread requires at least 2 arguments; 1 given > > Fair enough. I looked again at my spanking new copy of "Python Standard > Library" and noticed that in the example 'start_new_thread(worker, ())'. In > the example, worker() does not accept an argument. Hrm. > > In the spirit of blind flailing I attempted: > > thread.start_new_thread(write(the_madness),()) > > and got: > > Traceback (most recent call last): > File "dbwrite.py", line 21, in ? > thread.start_new_thread(write(the_madness), ()) > TypeError: first arg must be callable > > for my troubles. Since I don't have a clue what is going on this was not a > big surprize! :-) The problem is the slight misunderstanding of what happens when you put: thread.start_new_thread(write(the_madness),()) What you mean to say is: thread.start_new_thread(write, (the_madness,)). The whole point of creating a new thread is to invoke some function. The function may, or may not need arguments. To create a new thread, you need to supply the function you want to run, and any supplementary arguments. The function is obviously "write", and the only argument you are supplying is "the_madness". But when you put write(the_madness), the function is actually being executed, and then returns a value (looking at the code, it's the string 'ok'). So: thread.start_new_thread(write(the_madness),()) is evaluated to: thread.start_new_thread('ok', ()) and then the thread module complains because it is unable to run the function 'ok' (which is a string, not a function of any sort). So, once again, the corrected line is: thread.start_new_thread(write, (the_madness,)) Don't forget that because it's a tuple of one element, it has to have the comma after the first element. I would try this code out, but I don't have a database to test it on, and in all honesty, I can't be bothered. Hope it works though. :) Allan. From bill-bell@bill-bell.hamilton.on.ca Tue Jun 12 01:39:39 2001 From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 11 Jun 2001 20:39:39 -0400 Subject: [Tutor] Re: What am I missing?? In-Reply-To: Message-ID: <3B252C8B.2536.F64624F@localhost> DavidCraig@PIA.CA.GOV wrote, in part: > I am working through the python tutorial on "How to think like a > Computer Scientist in Python". > > I know its simple but I can't find why this does not work. This is > the distance() I have written. Below is the error message I get. > > # distance function > > def distance(x1, y1, x2, y2): > dx = x2 - x1 > dy = y2 - y1 > dsquared = dx**2 + dy**2 > result = sqrt(dsquared) > return result > > distance(1, 2, 4, 6) > NameError: name 'distance' is not defined I'd expect the lines showing your definition of the the function to appear more like the following. >>> def distance(x1, y1, x2, y2): ... dx=x2-x1 ... dy=y2-y1 ... dsquared=dx**2+dy**2 ... result=math.sqrt(dsquared) ... return result ... Note the little dots that appear at the beginning of eachof the lines other than the first. The fact that it doesn't suggests that you haven't entered the lines of code one at a time so that the Python interpreter can handle indentation properly. In any case, if you enter the 'def' line, press 'Enter' then enter the next line and press 'Enter' and so on then the interpreter will cope and your definition should work--almost (see below). When you enter your invokation line you should see a result like the following. >>> distance(1,2,4,6) 5.0 The other thing I notice (because I tripped over it myself) is that you use an unadorned 'import' statement to gain access to the sqrt function. As a consequence you will need to refer to it as math.sqrt (as shown in my code), rather than just sqrt. HTH (as people say). Bill Bill Bell, Software Developer From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 02:25:28 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 11 Jun 2001 18:25:28 -0700 (PDT) Subject: [Tutor] Threads.... More Despair.... In-Reply-To: <200106120004.f5C04ng07464@pop.nsacom.net> Message-ID: On Mon, 11 Jun 2001 kromag@nsacom.net wrote: > The following pathetic script attempts to summon up a thread, write to > a database and exit: Ok, let's take a look. > import win32com.client > import random > import time > import string > import thread > > engine=win32com.client.Dispatch("DAO.DBEngine.35") > db=engine.OpenDatabase("\windows\desktop\terror.mdb") > > > ## Function write() writes a list to the database > def write(inputtage): > time=inputtage[0] > data_string=inputtage[1] > db.Execute("insert into data values(%f, '%s')" %(time, data_string)) > return 'ok' > > tik_tok=time.time() > surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) > the_madness=(tik_tok, surprize) Looks ok so far. > thread.start_new_thread(write(the_madness)) There's a small problem here; the problem is that the 'write(the_madness)' part of this line is getting called too quickly. What I mean is that, for every command that is made of compound pieces, Python will execute the inner stuff first, and then pass the results off to the outer 'thread.start_new_thread( results of "write(the_madness)" )' stuff. The result is that thread.start_new_thread is only getting one thing, and that thing isn't something it can work with. This explains the error: > Traceback (most recent call last): > File "dbwrite.py", line 21, in ? > thread.start_new_thread(write(the_madness)) > TypeError: start_new_thread requires at least 2 arguments; 1 given The quickest way to fix this is the following line: thread.start_new_thread(write, (the_madness,)) which tells Python "Ok, we want to start a new thread. When it starts up, it should execute 'write', with 'the_madness' as it's first argument." The really tricky part is the last part: (the_madness,) because if we don't have that comma, Python won't be able to figure out that 'the_madness' should fit into inputtage. > Fair enough. I looked again at my spanking new copy of "Python > Standard Library" and noticed that in the example > 'start_new_thread(worker, ())'. In the example, worker() does not > accept an argument. Hrm. Yes, in that particular case, worker doesn't take any arguments, so the second thing we give start_new_thread turns out to be an empty tuple. But in your case, you need to send off your write() function the_madness as the first (and only) argument. With this in mind, the documentation on thread.start_new_thread() might make more sense now: """ start_new_thread (function, args[, kwargs]) Start a new thread. The thread executes the function function with the argument list args (which must be a tuple)... """ > for my troubles. Since I don't have a clue what is going on this was > not a big surprize! :-) You're getting closer. *grin* For reference, here's another example of a threaded program: ### import thread import time def fallingBridge(name, delay): print "The", name, "bridge is falling down..." time.sleep(delay) print "The", name, "bridge fell down!" if __name__ == '__main__': bridges = ['london', 'san mateo', 'golden gate'] delays = [1, 2, 3] for b, d in zip(bridges, delays): thread.start_new_thread(fallingBridge, (b, d)) print "All done!" ### And here it is in action: ### All done! >>> The golden gate bridge is falling down... The san mateo bridge is falling down... The london bridge is falling down... The london bridge fell down! The san mateo bridge fell down! The golden gate bridge fell down! ### Hmmm... I knew I forgot to tell my main thread to wait until all my threads were done. It's saying "All done!" a bit too quickly, and that's what motivates the need for more control over our threads. The 'threading' module allows us to do this to our Threads with join(), but that's for another message. *grin* Good luck! From kojo@hal-pc.org Tue Jun 12 02:51:23 2001 From: kojo@hal-pc.org (Kojo Idrissa) Date: Mon, 11 Jun 2001 20:51:23 -0500 Subject: [Tutor] time.strptime in Active State Python 2.1 Message-ID: <5.0.2.1.0.20010611204629.02055c78@Pop3.norton.antivirus> I'm trying to use that attribute of the time module, but I"m being told that the attribute DNE. According to page 172 of David Beazley's 'Python Essential Ref', it does exist. Is this a change from 1.5.2 (which the book is based on) to 2.1? Below are the screens from my interactive prompt. Thanks, PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> time.strptime('06/11/01 20:27:24',[]) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'time' module has no attribute 'strptime' **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo/ **************************** From allan.crooks@btinternet.com Tue Jun 12 02:58:10 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Tue, 12 Jun 2001 02:58:10 +0100 Subject: [Tutor] time.strptime in Active State Python 2.1 Message-ID: > PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see > 'Help/About PythonWin' for further copyright information. > > >>> time.strptime('06/11/01 20:27:24',[]) > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'time' module has no attribute 'strptime' You're trying to access the wrong function, I believe. >>> import time >>> dir(time) ['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', 'timez one', 'tzname'] >>> time.strftime >>> It's STRFTIME, if that's not clear. :) Allan. From kojo@hal-pc.org Tue Jun 12 03:07:08 2001 From: kojo@hal-pc.org (Kojo Idrissa) Date: Mon, 11 Jun 2001 21:07:08 -0500 Subject: [Tutor] time.strptime in Active State Python 2.1 In-Reply-To: Message-ID: <5.0.2.1.0.20010611210433.0205fe98@Pop3.norton.antivirus> I know about the STRFTIME function, but according to Python Ess. Ref, there's also a STRPTIME function. Maybe it was in 1.5.2 and it's gone in 2.1. If that's the case, how do I go about taking a string representinig a certain time and turn it into a tuple of the same form as returned by LOCALTIME? Thanks, At 02:58 AM 6/12/2001 +0100, you wrote: > > PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32. > > Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see > > 'Help/About PythonWin' for further copyright information. > > > > >>> time.strptime('06/11/01 20:27:24',[]) > > Traceback (most recent call last): > > File "", line 1, in ? > > AttributeError: 'time' module has no attribute 'strptime' > >You're trying to access the wrong function, I believe. > > >>> import time > >>> dir(time) >['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', >'ctime', >'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', >'timez >one', 'tzname'] > >>> time.strftime > > >>> > >It's STRFTIME, if that's not clear. :) > >Allan. **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo/ **************************** From allan.crooks@btinternet.com Tue Jun 12 03:21:28 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Tue, 12 Jun 2001 03:21:28 +0100 Subject: [Tutor] time.strptime in Active State Python 2.1 Message-ID: > I know about the STRFTIME function, but according to Python Ess. Ref, > there's also a STRPTIME function. Maybe it was in 1.5.2 and it's gone in 2.1. Sorry, I actually bothered to look at the time documentation in this time. :) It's very rare that they would remove a function from a module. The good news is strptime still exists. The bad news is, it's only available on "most Unix systems". Take a look for yourself at: http://www.python.org/doc/current/lib/module-time.html > If that's the case, how do I go about taking a string representinig a > certain time and turn it into a tuple of the same form as returned by > LOCALTIME? Ahh. Well, it's not provided in standard python, so you have to use modules elsewhere. I've had a look for you, and this one might be of use: http://www.fukt.hk-r.se/~flognat/hacks/strptime.py HTH, Allan. From allan.crooks@btinternet.com Tue Jun 12 05:22:43 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Tue, 12 Jun 2001 05:22:43 +0100 Subject: [Tutor] Uncallable class methods? Message-ID: Hi, Quick question about the following piece of code: >>> class X: .. def y(): .. print 'I am y of x.' Is there anyway that y can be invoked? My understanding is no, in which case, can anyone tell me why the interpreter doesn't complain about a class method being declared which does not have the minimum of one argument? Of course, considering the wealth of replies I received about my query about buffers, maybe I'm asking in the wrong place. :) Allan. From pobrien@orbtech.com Tue Jun 12 06:01:04 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Tue, 12 Jun 2001 00:01:04 -0500 Subject: [Tutor] Uncallable class methods? In-Reply-To: Message-ID: Hmmm. Very interesting question. You would think that something would complain sooner. Here is what I got: >>> class x: def y(): print 'Yo' >>> dir(x) ['__doc__', '__module__', 'y'] >>> x.y >>> x.y() Traceback (most recent call last): File "", line 1, in ? x.y() TypeError: unbound method y() must be called with instance as first argument >>> z = x() >>> z <__main__.x instance at 016BDC1C> >>> z.y() Traceback (most recent call last): File "", line 1, in ? z.y() TypeError: y() takes no arguments (1 given) >>> Kind of a funny catch-22 going on. For the total newbies, def y() should have been declared as def y(self), of which Allan is well aware. The point is why does python let us mess up so badly in the first place? And I do not know the answer to that question. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Allan Crooks Sent: Monday, June 11, 2001 11:23 PM To: tutor@python.org Subject: [Tutor] Uncallable class methods? Hi, Quick question about the following piece of code: >>> class X: .. def y(): .. print 'I am y of x.' Is there anyway that y can be invoked? My understanding is no, in which case, can anyone tell me why the interpreter doesn't complain about a class method being declared which does not have the minimum of one argument? Of course, considering the wealth of replies I received about my query about buffers, maybe I'm asking in the wrong place. :) Allan. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 06:13:04 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 11 Jun 2001 22:13:04 -0700 (PDT) Subject: [Tutor] Buffer's? In-Reply-To: Message-ID: On Mon, 11 Jun 2001, Allan Crooks wrote: > Can anyone explain to me what the buffer function actually does? I > can't find much mention about it in the Python documentation..... Hmmm! I've never encountered the buffer function before! Let's take a look... ### >>> buffer >>> print buffer.__doc__ buffer(object [, offset[, size]) -> object Creates a new buffer object which references the given object. The buffer will reference a slice of the target object from the start of the object (or at the specified offset). The slice will extend to the end of the target object (or with the specified size). ### Don't worry if this doesn't make sense to you; it's gibberish to me too... *grin* I wonder why such a function would be useful? There's a reference to a thread on the main Python list that talks about buffer() here: http://mail.python.org/pipermail/python-list/1999-October/013886.html >From reading this, it sounds like buffer is meant to make it easy to pass in huge slices of information back and forth between functions. Wait, wait! I see now! Buffers allow us to take "slices" of our lists. Unlike normal slices though, these buffers don't make a copy of the original list. To see why buffers are useful, let's show that regular Python slices are actually copies of an original list: ### >>> mylist = range(5) >>> mylist [0, 1, 2, 3, 4] >>> myslice = mylist[-2:] >>> myslice [3, 4] >>> myslice[0] = 'three' >>> myslice ['three', 4] >>> mylist [0, 1, 2, 3, 4] ### So that's how slices work, by copying the section we're interested in as a whole new list. Normally, this copying behavior is a good thing, because it lets us fiddle around with small pieces of a list without having disturbed the main list. However, it's a nightmare if we need to work with huge slices, since copying can be expensive. Buffers, then, act like slices: the only difference is that they shouldn't copy the original list. It's a little hard for me to show practical examples using buffers, because, frankly, I've haven't worked with them yet. *grin* Also, the documentation on them seems really sparse --- I suspect that it's not quite popular yet, since Python lists apparently doesn't support the buffer interface yet. Still, you might want to ask on comp.lang.python and see if anyone is using it. There's another reference to Buffer object in the Python/C API here: http://python.org/doc/current/api/bufferObjects.html which suggests that buffer() is a sort of function that one shouldn't touch unless you're a real efficiency enthusiast. Sorry about the incomplete information! From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 06:27:55 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 11 Jun 2001 22:27:55 -0700 (PDT) Subject: [Tutor] Uncallable class methods? In-Reply-To: Message-ID: On Tue, 12 Jun 2001, Patrick K. O'Brien wrote: > Hmmm. Very interesting question. You would think that something would > complain sooner. Here is what I got: I suspect it has to do with the way Python does things dynamically. For example, typing out the following: ### def test1(): foobar ### doesn't break, at least as long as we don't actually call test1(). But when we actually do call test1(), that's when Python looks inside and sees that 'foobar' hasn't been defined. Likewise, when we're defining a class's members, like the example: > >>> class x: > def y(): > print 'Yo' Python doesn't call y() yet, and so it doesn't detect the error about the missing "self" argument. As a wild guess, I think Python does it this way to reduce the number of rules it needs to check as it reads our definitions. When we're defining "members" of a class, we're using the framework for defining regular functions, with the small rule that the first argument will magically get filled in with an instance... but the procedure that reads def's doesn't really need to know about the special role of 'self'. I believe that the PyChecker utility here: http://pychecker.sourceforge.net does check for the kind of bugs like this. > Kind of a funny catch-22 going on. For the total newbies, def y() should > have been declared as def y(self), of which Allan is well aware. The point > is why does python let us mess up so badly in the first place? And I do not > know the answer to that question. It's probably to make the Python implementors lives a little easier: they can reuse the same kind of definition-reading code without having to special-case it for class definitions. The consequence, unfortunately, is that it isn't quite as helpful as we'd like it; the parser isn't context senstive. But perhaps this can be fixed! You might want to raise this question to them; this definitely sounds like the sort of thing that catches people off guard. > Of course, considering the wealth of replies I received about my query about > buffers, maybe I'm asking in the wrong place. :) *head in shame* From kojo@hal-pc.org Tue Jun 12 06:42:17 2001 From: kojo@hal-pc.org (Kojo Idrissa) Date: Tue, 12 Jun 2001 00:42:17 -0500 Subject: [Tutor] time.strptime in Active State Python 2.1 In-Reply-To: Message-ID: <5.0.2.1.0.20010612004110.00ae7328@Pop3.norton.antivirus> Thanks Allan, this looks like just what I was looking for. I'll bring this module over to my Win2K partition and add it to my list of "Reasons to use Linux more". :-) At 03:21 AM 6/12/2001 +0100, you wrote: > > I know about the STRFTIME function, but according to Python Ess. Ref, > > there's also a STRPTIME function. Maybe it was in 1.5.2 and it's gone > in 2.1. > >Sorry, I actually bothered to look at the time documentation in this time. :) > >It's very rare that they would remove a function from a module. > >The good news is strptime still exists. The bad news is, it's only >available on "most Unix systems". > >Take a look for yourself at: >http://www.python.org/doc/current/lib/module-time.html > > > If that's the case, how do I go about taking a string representinig a > > certain time and turn it into a tuple of the same form as returned by > > LOCALTIME? > >Ahh. Well, it's not provided in standard python, so you have to use >modules elsewhere. > >I've had a look for you, and this one might be of use: > >http://www.fukt.hk-r.se/~flognat/hacks/strptime.py > >HTH, >Allan. > > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo/ **************************** From pobrien@orbtech.com Tue Jun 12 06:47:05 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Tue, 12 Jun 2001 00:47:05 -0500 Subject: [Tutor] SubDictionaries or am I reinventing a wheel? Message-ID: Imagine that you have a dictionary with a multipart key and you want to extract a new dictionary that is a subset of the existing dictionary based on matching a few of the leading elements that make up the key. For example, GoldMine stores multiple record types in some of its database files. So I have a dictionary with the table name and record type code as the key. gmRecordTypes = { # Table, Type, Description ('CAL', 'A'): 'Appointment', ('CAL', 'C'): 'Call back', ('CAL', 'D'): 'To-do', ('CAL', 'E'): 'Event', ('CAL', 'F'): 'Literature fulfillment', ('CAL', 'M'): 'Message', ('CAL', 'O'): 'Other', ('CAL', 'Q'): 'Queued e-mail', ('CAL', 'S'): 'Sales potential', ('CAL', 'T'): 'Next action', ('CONTHIST', 'A'): 'Appointment', ('CONTHIST', 'C'): 'Phone call', ('CONTHIST', 'D'): 'To-do', ('CONTHIST', 'E'): 'Event', ('CONTHIST', 'F'): 'Literature fulfillment', ('CONTHIST', 'L'): 'Form', ('CONTHIST', 'M'): 'Sent message', ('CONTHIST', 'O'): 'Other', ('CONTHIST', 'S'): 'Sale', ('CONTHIST', 'T'): 'Next action', } Now let's say I wanted a function that would return a new dictionary of just the record types and descriptions for the CONTHIST table. Think of this as sort of a query against a database table - select type, description from gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of dictionaries like this and that you wanted the function to be able to select based on one matching element or several matching elements of the key. Well, I did and here is what I came up with. # partmatch can be a single value or any valid sequence for a dictionary key or portion thereof. def subDictionary(dictionary, partmatch=None): """Return a subset of a dictionary based on a partial key match.""" if partmatch == None: return dictionary else: subd = {} partsize = len(partmatch) if partsize == 1: # Reduce single element sequences to single elements. partmatch = partmatch[0] for key in dictionary.keys(): if partsize == 1: # Reduce single element sequences to single elements. keypart = key[0] else: keypart = key[:partsize] if keypart == partmatch: if len(key[partsize:]) == 1: # Simplify the new key by reducing it to a single object if possible. newkey = key[partsize] else: newkey = key[partsize:] subd[newkey] = dictionary[key] return subd Now, I either came up with something nifty that will be useful to me and maybe others, or I just spent a good couple of hours reinventing the wheel. Does anyone know of any Python module that does this already? Is this a good approach to the problem I described, or am I off my rocker? Somehow this sort of manipulation seems like it should be part of the core of python in the way that keys() and values() are already there. --- Patrick K. O'Brien Orbtech "I am, therefore I think." From jacqueline_juselius@yahoo.com Tue Jun 12 07:16:46 2001 From: jacqueline_juselius@yahoo.com (jacqueline juselius) Date: Mon, 11 Jun 2001 23:16:46 -0700 (PDT) Subject: [Tutor] reading sequence codes in from a file Message-ID: <20010612061646.78540.qmail@web14310.mail.yahoo.com> Hi folks, I have a config file which contain list of sequence code pairs. eg. ruleFile rule1,\272,\377 rule2,\280,\375 I read these lines in with : lines = open(ruleFile).readlines() and split the line and store the last two columns into a list, creating a translation list of before and after values. I then read another file text file and see if I can find any of these special characters that's in the first column and translate them to what ever is in the second column. My problem is that when I read the rule File I don't get an escape sequence but a string. eg. in python I can say a = "\272" print a and I will get a funny character (a's length = 1) but when I read the line from a file I get double slashes "//272", its length being 4 instead of one. ie. python has taken it as a string. My thought was that I could parse out "272" and then someohow translate it to "/272" with a length of 1. Does anyone know how to do this or how to read an escape sequence in from a file and have it treated as an escape sequence and not a string? I tried the chr() function but that only handles the 256 ascii chars. Thanks, Jacqueline __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From alan.gauld@freenet.co.uk Tue Jun 12 08:17:56 2001 From: alan.gauld@freenet.co.uk (Alan Gauld) Date: Tue, 12 Jun 2001 07:17:56 +0000 Subject: [Tutor] New Web tutor version Message-ID: <3.0.1.32.20010612071756.013a999c@mail.freenet.co.uk> Hi gang, I'm happy to announce a new translation of my Web tutor in the Czech language. This is a very professional translation and has revamped the look of the site too. http://www.crosswinds.net/~agauld/czech/ OR to see the home site, where they are using Python in anger: ------------------ The Czech version of your book is displayed on our Czech web site, on http://www.datapartner.cz please go to "Poradna" (something like Guidance) and there on "Jak se naucit programovat" (the name of your book in Czech language.) ------------------ Unfortunately the changes mean it only works in Internet Explorer - I've asked them to fix the problems... While I was at it the downloadable version in all languages is now in tar/gzip format since that is readable in winzip etc as well as Linux. Enjoy, Alan G From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 09:02:38 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 01:02:38 -0700 (PDT) Subject: [Tutor] reading sequence codes in from a file In-Reply-To: <20010612061646.78540.qmail@web14310.mail.yahoo.com> Message-ID: On Mon, 11 Jun 2001, jacqueline juselius wrote: > but when I read the line from a file I get double > slashes "//272", its length being 4 instead of one. > ie. python has taken it as a string. > > My thought was that I could parse out "272" and then > someohow translate it to "/272" with a length of 1. This is perfectly possible. (For this message, I'm assuming that you're using Python 1.52; things will look slightly different in Python 2.1, although the ideas are the same.) > Does anyone know how to do this or how to read an > escape sequence in from a file and have it treated as > an escape sequence and not a string? > > I tried the chr() function but that only handles the > 256 ascii chars. The only problem is that when you're writing '\272', you're actually writing a number in base-8 "octal". That is, '\272' doesn't stand for the number 272, but for: 2 * (8**2) = 128 + 7 * (8**1) = 56 + 2 * (8**0) = 2 ------------- -------- 186 which is why you're getting that error message with chr(): it's way out of its comfortable domain, and doesn't know what to do with a character code larger than 256. If you have eight fingers, base-8 this will make sense. However, if you're not octafingered, then we can use Python to do this converting work for us: ### >>> int('272', 8) 186 ### which, thankfully, is the same as the manual calculation we did above. The int() function can take in an optional 'base' as its second number: we just need to tell Python to compensate for 8-fingeredness, and it can do it. Applying chr() on this number should work much more nicely: ### >>> chr(186) '\272' ### Whew! Anyway, I think I wandered a bit, so please ask questions, and we'll try to clarify things. Good luck! From lonetwin@yahoo.com Tue Jun 12 10:22:43 2001 From: lonetwin@yahoo.com (steve) Date: Tue, 12 Jun 2001 14:52:43 +0530 Subject: [Tutor] Uncallable class methods? In-Reply-To: References: Message-ID: <01061214524307.11131@mercury.in.cqsl.com> Hi all, This here is a nice question vvvvvvvvv > Quick question about the following piece of code: > >>> class X: > > .. def y(): > .. print 'I am y of x.' > > Is there anyway that y can be invoked? My understanding is no, in which > case, can anyone tell me why the interpreter doesn't complain about a c= lass > method being declared which does not have the minimum of one argument? Well, here's how I see it as...I think it's a pretty good thing that pyt= hon=20 complains when U try to use an "unbound" function, but does not when u de= fine=20 it .....'cos by doing that I can ensure that these functions are to be us= ed=20 "only" within the class itself.....kinda like a "private" function....if = u=20 really do require to use something that u defined for the class but did n= ot=20 mean an object of the class to use it, well define it outside the class a= nd=20 make it available to the class by importing it.....else make it a "valid"= =20 function of the class. Like I said ealier....just my thoughts....I've never come across the need= to=20 use an "unbound" funtion outside a class....but then again, I haven't yet= =20 solved all the world's problems too. Peace Steve --=20 |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##||=09 |||/\##|||||||||##/\||=09 |/ \#########/ \=09 |\ \#######/ /=09 ||\____/#######\____/|=09 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09 Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D From a.dijkstra03@kpn.com Tue Jun 12 10:22:36 2001 From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com) Date: Tue, 12 Jun 2001 11:22:36 +0200 Subject: [Tutor] newbie help..image in toplevelwindow? Message-ID: Hi there, This is one of my first attempts building a application with Tkinter. Could anyone explain to me what i'm doing wrong? I'm trying to insert a image in the toplevel window. I'm using win NT and python2.1. Thanks in advance regards Arjen from Tkinter import * from whrandom import choice from string import upper from re import sub kleur=['red', 'yellow', 'brown', 'green', 'purple', 'black', 'orange', 'white', 'blue'] alist=[] klos='.....\n moet koffie halen!!!' best=open('koffielijst', 'r') x=best.readlines() for item in x: a=sub('\n', '', item) alist.append(a) best.close() def kiezen(): kl=choice(kleur) klos=upper(choice(alist)) + '\n moet koffie halen!!!' label.configure(text=klos, fg=kl) def nieuw(): invoer=entry.get() if invoer != '': alist.append(invoer) toev=open('koffielijst', 'a') toev.write(invoer + '\n') toev.close() lijst.insert(END, invoer) entry.delete(0, END) return alist def opslaan(): opsl=open('koffielijst', 'w') for item in alist: opsl.write(item + '\n') opsl.close() def deleteButtonClick(): indicies = lijst.curselection() indicies = [int(index) for index in indicies] # Cast indicies to ints indicies.sort() indicies.reverse() for index in indicies: lijst.delete(index) alist.pop(index) opslaan() return alist def newwin(): wat=Toplevel() fr=Frame(wat) t=Label(fr, text='Versie 1.0', fg='red', bg='white') t.pack(pady=10) filename='PythonPoweredSmall.gif' img = PhotoImage(file=filename) hm = Label(fr, image=img) hm.pack() wat.title('info') fr.pack() top=Tk() label=Label(top, text=klos, font='Times 30 bold', fg='black') label.pack() menubar = Menu(top) filemenu=Menu(menubar, tearoff=0) filemenu.add_command(label="?????", command=newwin) top.config(menu=menubar) menubar.add_cascade(label="informatie", menu=filemenu) frame=Frame(top, bd=20, relief=SUNKEN) frame.pack(side=LEFT) entry=Entry(frame, width=23) entry.pack() frame1=Frame(frame) frame1.pack(fill=X) knop=Button(frame1, text='toevoegen', command=nieuw) knop.pack(side=LEFT) deleteButton = Button(frame1, text='verwijderen', command=deleteButtonClick) deleteButton.pack(fill=X) scrollbar=Scrollbar(frame) scrollbar.pack(side=RIGHT, fill=Y) lijst=Listbox(frame, height=5, width=20, yscrollcommand=scrollbar.set) for item in alist: lijst.insert(END, item) lijst.pack(side=BOTTOM) scrollbar.config(command=lijst.yview) Kies=Button(top, text='kiezen', font='Times 15', command=kiezen) ##Kies.bind('') Kies.pack(fill=X) quit=Button(top, text='afsluiten', font='Times 15', command=top.quit) quit.pack(fill=X) #filename='PythonPowered.gif' #img = PhotoImage(file=filename) #hm=Label(top, image=img) #hm.pack(pady=30) filename1='koffie.gif' img1 = PhotoImage(file=filename1) hm1=Label(top, image=img1) hm1.pack(pady=18) top.title(' KOFFIEMACHINE') mainloop() From scarblac@pino.selwerd.nl Tue Jun 12 10:23:01 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 12 Jun 2001 11:23:01 +0200 Subject: [Tutor] Uncallable class methods? In-Reply-To: <01061214524307.11131@mercury.in.cqsl.com>; from lonetwin@yahoo.com on Tue, Jun 12, 2001 at 02:52:43PM +0530 References: <01061214524307.11131@mercury.in.cqsl.com> Message-ID: <20010612112301.A30501@pino.selwerd.nl> On 0, steve wrote: > Well, here's how I see it as...I think it's a pretty good thing that python > complains when U try to use an "unbound" function, but does not when u define > it .....'cos by doing that I can ensure that these functions are to be used > "only" within the class itself. You can't use them within the class itself either. -- Remco Gerlich From alan.gauld@bt.com Tue Jun 12 10:21:48 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 12 Jun 2001 10:21:48 +0100 Subject: [Tutor] Uncallable class methods? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D810@mbtlipnt02.btlabs.bt.co.uk> > Quick question about the following piece of code: > > >>> class X: > .. def y(): > .. print 'I am y of x.' > > Is there anyway that y can be invoked? Not that I know of. It seems strange since this would be a reasonable thing to do - define a class method. But altho' Python allows the definition of class attributes it doesn't work with class methods(altho' it allows the "definition" of them it doesn't provide any way to call them - doh! > doesn't complain about a class method being declared which > does not have the minimum of one argument? Coz class methods shouldn't have an instance...? Instance methods shpould have but classs methods shouldn't. But Python doesn't support class methods - yet... This is not the most helpful of posts but does confirm that there is a hole somewhere. Maybe Mr Peters can comment? Alan G. From r.b.rigilink@chello.nl Tue Jun 12 10:58:16 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Tue, 12 Jun 2001 11:58:16 +0200 Subject: [Tutor] Uncallable class methods? References: Message-ID: <3B25E7B8.CC309BCB@chello.nl> Allan Crooks wrote: > > Hi, > > Quick question about the following piece of code: > > >>> class X: > .. def y(): > .. print 'I am y of x.' > > Is there anyway that y can be invoked? My understanding is no, in which case, can anyone tell me why the interpreter doesn't complain about a class method being declared which does not have the minimum of one argument? > Actually, there is. >>> X.__dict__['y']() I am y of x. It's useless in practice, and I don't think this is the reason the implementors chose to allow the code. However it does illustrate what happens under the hood: Your code creates a function object and binds it to name 'y' in namespace 'X' Consider: >>> X.y >>> X.__dict__['y'] >>> x = X() >>> x.y I.e. only when there's an attribute look-up for 'y' in 'x'/'X' does the function become a bound/unbound method, depending on whether the attribute was looked up in an instance is a class object. Also consider: class X: pass def y(): print 'I am y of x.' X.y = y del y which is completely equivalent to your code. You're proposing to make the simple name-binding operation X.y = y raise an error in this case. It's obvious to me that that isn't right. But I can't really tell you why. Which means it's not really obvious ;) Hope this sort of answers your question. Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From r.b.rigilink@chello.nl Tue Jun 12 11:34:47 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Tue, 12 Jun 2001 12:34:47 +0200 Subject: [Tutor] newbie help..image in toplevelwindow? References: Message-ID: <3B25F047.122B511E@chello.nl> a.dijkstra03@kpn.com wrote: > > Hi there, > > This is one of my first attempts building a application with Tkinter. > Could anyone explain to me what i'm doing wrong? I'm trying to insert a > image in the toplevel window. I'm using win NT and python2.1. > Hoi Arjen, I didn't try the code, but I think it may be as simple as: > top.title(' KOFFIEMACHINE') top.pack() > > mainloop() If it isn't, let me know. Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From rob@jam.rr.com Tue Jun 12 12:04:09 2001 From: rob@jam.rr.com (Rob Andrews) Date: Tue, 12 Jun 2001 06:04:09 -0500 Subject: [Tutor] New Web tutor version References: <3.0.1.32.20010612071756.013a999c@mail.freenet.co.uk> Message-ID: <3B25F729.F0C48E7C@jam.rr.com> Alan Gauld wrote: > > Hi gang, > > I'm happy to announce a new translation of my > Web tutor in the Czech language. This is a very > professional translation and has revamped the > look of the site too. > > http://www.crosswinds.net/~agauld/czech/ > > OR to see the home site, where they are using Python in anger: > ------------------ > The Czech version of your book is displayed on our Czech > web site, on > > http://www.datapartner.cz > > please go to "Poradna" (something like Guidance) and there > on "Jak se naucit programovat" (the name of your book in > Czech language.) > ------------------ > > Unfortunately the changes mean it only works in > Internet Explorer - I've asked them to fix the > problems... > > While I was at it the downloadable version in all > languages is now in tar/gzip format since that is > readable in winzip etc as well as Linux. > > Enjoy, > > Alan G > Congrats, Alan! I finally have a good excuse to learn some Czech. I'll update your Useless link to reflect the news. Rob -- As foretold by Nostradamus.... Useless Python! http://www.lowerstandard.com/python From a.dijkstra03@kpn.com Tue Jun 12 12:10:55 2001 From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com) Date: Tue, 12 Jun 2001 13:10:55 +0200 Subject: [Tutor] newbie help..image in toplevelwindow? Message-ID: Hoi Roeland, No, that didn't work too. I now get the following message: Traceback (most recent call last): File "C:\Python21\mijnscripts\koffiemach.py", line 118, in ? top.pack() AttributeError: Tk instance has no attribute 'pack' Does it help you any futher? Please let me know. Tanks anyway Arjen -----Oorspronkelijk bericht----- Van: Roeland Rengelink [mailto:r.b.rigilink@chello.nl] Verzonden: dinsdag 12 juni 2001 12:35 Aan: a.dijkstra03@kpn.com CC: tutor@python.org Onderwerp: Re: [Tutor] newbie help..image in toplevelwindow? a.dijkstra03@kpn.com wrote: > > Hi there, > > This is one of my first attempts building a application with Tkinter. > Could anyone explain to me what i'm doing wrong? I'm trying to insert a > image in the toplevel window. I'm using win NT and python2.1. > Hoi Arjen, I didn't try the code, but I think it may be as simple as: > top.title(' KOFFIEMACHINE') top.pack() > > mainloop() If it isn't, let me know. Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From scarblac@pino.selwerd.nl Tue Jun 12 12:30:57 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 12 Jun 2001 13:30:57 +0200 Subject: [lonetwin@yahoo.com: Re: [Tutor] Uncallable class methods?] Message-ID: <20010612133057.B30814@pino.selwerd.nl> Steve accidentally mailed his reply only to me. ----- Forwarded message from steve ----- Delivered-To: scarblac@pino.selwerd.nl From: steve Date: Tue, 12 Jun 2001 16:54:55 +0530 X-Mailer: KMail [version 1.1.99] To: Remco Gerlich In-Reply-To: <20010612112301.A30501@pino.selwerd.nl> Subject: Re: [Tutor] Uncallable class methods? Hey there, > On 0, steve wrote: > > Well, here's how I see it as...I think it's a pretty good thing that > > python complains when U try to use an "unbound" function, but does not > > when u define it .....'cos by doing that I can ensure that these > > functions are to be used "only" within the class itself. There ^^^^^^^^, all that was me trying to be a smart-ass, I'm sorry....tho' what I actually was trying to say was : ...kinda like a "private" function....if u really do require to use something that u defined for the class but did not mean an object of the class to use it, well define it outside the class like in.....within the same module/file. I messed up, I'm sorry (guess my fundas are still weak)....thanx Remco for correcting me ....(by doing that U made sure I "always" remembered that :) ) Peace Steve -- |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##|| |||/\##|||||||||##/\|| |/ \#########/ \ |\ \#######/ / ||\____/#######\____/| ===================================== Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! ==================================== ----- End forwarded message ----- From arcege@speakeasy.net Tue Jun 12 12:35:12 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Tue, 12 Jun 2001 07:35:12 -0400 (EDT) Subject: [Tutor] newbie help..image in toplevelwindow? In-Reply-To: from "a.dijkstra03@kpn.com" at Jun 12, 2001 11:22:36 AM Message-ID: <200106121135.f5CBZDO13254@dsl092-074-184.bos1.dsl.speakeasy.net> a.dijkstra03@kpn.com wrote > This is one of my first attempts building a application with Tkinter. > Could anyone explain to me what i'm doing wrong? I'm trying to insert a > image in the toplevel window. I'm using win NT and python2.1. You need to keep the image until the window is destroyed. To deal with the simple problem now, change the function to: # first create a variable set to None, we'll populate it only once _newwin_img = None def newwin(): global _newwin_img # not a local variable to the function wat=Toplevel() fr=Frame(wat) t=Label(fr, text='Versie 1.0', fg='red', bg='white') t.pack(pady=10) filename='PythonPoweredSmall.gif' if not _newwin_img: # if not populated _newwin_img = PhotoImage(file=filename) hm = Label(fr, image=_newwin_img) hm.pack() wat.title('info') fr.pack() Because of the interactions between Python and Tcl for Tkinter, the image will be destroyed when the Python reference is destroy, which is the end of the function. [Most people talk about "scope" in programming, and do not realize that "extent" is often a more important concept.] -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From a.dijkstra03@kpn.com Tue Jun 12 12:38:53 2001 From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com) Date: Tue, 12 Jun 2001 13:38:53 +0200 Subject: [Tutor] newbie help..image in toplevelwindow? Message-ID: YESS. It works! Thank you very much. -----Oorspronkelijk bericht----- Van: Michael P. Reilly [mailto:arcege@dsl092-074-184.bos1.dsl.speakeasy.net] Verzonden: dinsdag 12 juni 2001 13:35 Aan: a.dijkstra03@kpn.com CC: tutor@python.org Onderwerp: Re: [Tutor] newbie help..image in toplevelwindow? a.dijkstra03@kpn.com wrote > This is one of my first attempts building a application with Tkinter. > Could anyone explain to me what i'm doing wrong? I'm trying to insert a > image in the toplevel window. I'm using win NT and python2.1. You need to keep the image until the window is destroyed. To deal with the simple problem now, change the function to: # first create a variable set to None, we'll populate it only once _newwin_img = None def newwin(): global _newwin_img # not a local variable to the function wat=Toplevel() fr=Frame(wat) t=Label(fr, text='Versie 1.0', fg='red', bg='white') t.pack(pady=10) filename='PythonPoweredSmall.gif' if not _newwin_img: # if not populated _newwin_img = PhotoImage(file=filename) hm = Label(fr, image=_newwin_img) hm.pack() wat.title('info') fr.pack() Because of the interactions between Python and Tcl for Tkinter, the image will be destroyed when the Python reference is destroy, which is the end of the function. [Most people talk about "scope" in programming, and do not realize that "extent" is often a more important concept.] -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From alan.gauld@bt.com Tue Jun 12 13:04:09 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 12 Jun 2001 13:04:09 +0100 Subject: [Tutor] Useless challenge? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D812@mbtlipnt02.btlabs.bt.co.uk> I was thinking the other day that there doesn't seem to be any kind of equivalent to the Tk widget tour demo that starts when you install Tcl/Tk. I was also thinking that since its all written in Tcl/Tk it should be fairly easy(technically speaking) to translate it into Python/Tkinter. I also thought that since it is essentially a lot of little applets inside a containing structure that it would be a good challenge for the Useless Python site - list the applets to be converted and get people to build the Python versions. This could then allow some extras to be added such as the PMW widgets too. Then, for a real test, convert it all to wxPython! ;-) What think yez? Alan g ------------------------------ British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 1800000. This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. From r.b.rigilink@chello.nl Tue Jun 12 13:23:29 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Tue, 12 Jun 2001 14:23:29 +0200 Subject: [Tutor] SubDictionaries or am I reinventing a wheel? References: Message-ID: <3B2609C1.34A88AAF@chello.nl> "Patrick K. O'Brien" wrote: Hi Patrick, > > Imagine that you have a dictionary with a multipart key and you want to > extract a new dictionary that is a subset of the existing dictionary based > on matching a few of the leading elements that make up the key. For example, > GoldMine stores multiple record types in some of its database files. So I > have a dictionary with the table name and record type code as the key. > > gmRecordTypes = { # Table, Type, Description > ('CAL', 'A'): 'Appointment', > } > Have you considered using nested dictionaries for this, i.e.: gmRecordTypes = {'CAL': {'A': 'Appointment', 'C': 'Call back', ... 'T': 'Next action}, 'CONTHIST': {'A':'Appointment', 'C': 'Call back', ... 'T': 'Next action'}} You can then get at the subdictionaries through subd = gmRecordTypes['CAL'] and individual values with val = gmRecordTypes['CAL']['A'] This is sort of the standard approach for what you seem to describe. > Now let's say I wanted a function that would return a new dictionary of just > the record types and descriptions for the CONTHIST table. Think of this as > sort of a query against a database table - select type, description from > gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of > dictionaries like this and that you wanted the function to be able to select > based on one matching element or several matching elements of the key. Well, > I did and here is what I came up with. > > # partmatch can be a single value or any valid sequence for a dictionary key > or portion thereof. > > def subDictionary(dictionary, partmatch=None): > """Return a subset of a dictionary based on a partial key match.""" > if partmatch == None: > return dictionary Are you sure that subDictionary(dictionary) should return dictionary itself, while subDictionary(dictionary, ()) should return a copy? > else: > subd = {} > partsize = len(partmatch) > if partsize == 1: # Reduce single element sequences to single > elements. > partmatch = partmatch[0] > for key in dictionary.keys(): > if partsize == 1: # Reduce single element sequences to single > elements. > keypart = key[0] > else: > keypart = key[:partsize] > if keypart == partmatch: > if len(key[partsize:]) == 1: # Simplify the new key by > reducing it to a single object if possible. > newkey = key[partsize] > else: > newkey = key[partsize:] > subd[newkey] = dictionary[key] > return subd > Here's my somewhat more concise version. Note that I also test if key and partmatch are of the same type. def subDictionary(dictionary, partmatch=()): """Return a subset of a dictionary based on a partial key match.""" subd = {} for key, val in dictionary.items(): if partial_match(partmatch, key): newkey = key[len(partmatch):] if len(newkey) == 1: newkey = newkey[0] subd[newkey] = val return subd def partial_match(first, second): '''Match two sequences returns 0 if type(first) != type(second) returns 1 if second[:len(first)] == first returns 0 otherwise ''' if type(first) != type(second): return 0 return second[:len(first)] == first > Now, I either came up with something nifty that will be useful to me and > maybe others, or I just spent a good couple of hours reinventing the wheel. > Does anyone know of any Python module that does this already? Is this a good > approach to the problem I described, or am I off my rocker? Hey, your code works, which is the only practical definition of 'good approach' > Somehow this > sort of manipulation seems like it should be part of the core of python in > the way that keys() and values() are already there. > This sounds like a nasty question, but think of it a an exercise. Exactly what kind of manipulation do you mean? Remember keys() and values() can be described exactly in one sentence only. Try to find the one-sentence description for your proposed extensions. You could then try building your own UserDict class that implements these manipulations as additional methods. Hope this helps, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From rob@jam.rr.com Tue Jun 12 13:29:15 2001 From: rob@jam.rr.com (Rob Andrews) Date: Tue, 12 Jun 2001 07:29:15 -0500 Subject: [Tutor] Useless challenge? References: <5104D4DBC598D211B5FE0000F8FE7EB20751D812@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <3B260B1B.918DF86B@jam.rr.com> alan.gauld@bt.com wrote: > > I was thinking the other day that there doesn't seem to be any > kind of equivalent to the Tk widget tour demo that starts when > you install Tcl/Tk. I was also thinking that since its all > written in Tcl/Tk it should be fairly easy(technically speaking) > to translate it into Python/Tkinter. > > I also thought that since it is essentially a lot of little > applets inside a containing structure that it would be a > good challenge for the Useless Python site - list the applets > to be converted and get people to build the Python versions. > > This could then allow some extras to be added such as the > PMW widgets too. > > Then, for a real test, convert it all to wxPython! ;-) > > What think yez? > > Alan g > Sounds nifty to me! In fact, I've already added this to the page. Now, if only my web hosting service felt inclined to accept connections from me, I'd just upload it. I guess I'll have to go to work and do it again. It's really amazing. Ever since it was sold to new owners a few weeks back, my host will refuse to allow me to ftp approximately 1/3 of the time, but only from this location. When I move to a new host, there will be great rejoicing in the land. Have a Useless Day, Rob -- As foretold by Nostradamus.... Useless Python! http://www.lowerstandard.com/python From pobrien@orbtech.com Tue Jun 12 13:46:39 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Tue, 12 Jun 2001 07:46:39 -0500 Subject: [Tutor] SubDictionaries or am I reinventing a wheel? In-Reply-To: <3B2609C1.34A88AAF@chello.nl> Message-ID: D'oh!!! (Followed by a smack to the forehead.) Boy you nailed this one, Roeland! I knew I was overlooking something very obvious (to everyone but me ). No, I did not consider using nested dictionaries. But you can bet I'll never make that mistake again. Ouch! Your example of being able to do val = gmRecordTypes['CAL']['A'] was exactly the kind of simple, elegant language feature I just knew had to be available in python. I hope that explains the final question of my original post, which in no way did I intend to sound "nasty". My apologies to anyone who got that impression. Thank you very much for helping me see the error of my ways! --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Roeland Rengelink Sent: Tuesday, June 12, 2001 7:23 AM To: pobrien@orbtech.com Cc: Python Tutor Subject: Re: [Tutor] SubDictionaries or am I reinventing a wheel? "Patrick K. O'Brien" wrote: Hi Patrick, > > Imagine that you have a dictionary with a multipart key and you want to > extract a new dictionary that is a subset of the existing dictionary based > on matching a few of the leading elements that make up the key. For example, > GoldMine stores multiple record types in some of its database files. So I > have a dictionary with the table name and record type code as the key. > > gmRecordTypes = { # Table, Type, Description > ('CAL', 'A'): 'Appointment', > } > Have you considered using nested dictionaries for this, i.e.: gmRecordTypes = {'CAL': {'A': 'Appointment', 'C': 'Call back', ... 'T': 'Next action}, 'CONTHIST': {'A':'Appointment', 'C': 'Call back', ... 'T': 'Next action'}} You can then get at the subdictionaries through subd = gmRecordTypes['CAL'] and individual values with val = gmRecordTypes['CAL']['A'] This is sort of the standard approach for what you seem to describe. > Now let's say I wanted a function that would return a new dictionary of just > the record types and descriptions for the CONTHIST table. Think of this as > sort of a query against a database table - select type, description from > gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of > dictionaries like this and that you wanted the function to be able to select > based on one matching element or several matching elements of the key. Well, > I did and here is what I came up with. > > # partmatch can be a single value or any valid sequence for a dictionary key > or portion thereof. > > def subDictionary(dictionary, partmatch=None): > """Return a subset of a dictionary based on a partial key match.""" > if partmatch == None: > return dictionary Are you sure that subDictionary(dictionary) should return dictionary itself, while subDictionary(dictionary, ()) should return a copy? > else: > subd = {} > partsize = len(partmatch) > if partsize == 1: # Reduce single element sequences to single > elements. > partmatch = partmatch[0] > for key in dictionary.keys(): > if partsize == 1: # Reduce single element sequences to single > elements. > keypart = key[0] > else: > keypart = key[:partsize] > if keypart == partmatch: > if len(key[partsize:]) == 1: # Simplify the new key by > reducing it to a single object if possible. > newkey = key[partsize] > else: > newkey = key[partsize:] > subd[newkey] = dictionary[key] > return subd > Here's my somewhat more concise version. Note that I also test if key and partmatch are of the same type. def subDictionary(dictionary, partmatch=()): """Return a subset of a dictionary based on a partial key match.""" subd = {} for key, val in dictionary.items(): if partial_match(partmatch, key): newkey = key[len(partmatch):] if len(newkey) == 1: newkey = newkey[0] subd[newkey] = val return subd def partial_match(first, second): '''Match two sequences returns 0 if type(first) != type(second) returns 1 if second[:len(first)] == first returns 0 otherwise ''' if type(first) != type(second): return 0 return second[:len(first)] == first > Now, I either came up with something nifty that will be useful to me and > maybe others, or I just spent a good couple of hours reinventing the wheel. > Does anyone know of any Python module that does this already? Is this a good > approach to the problem I described, or am I off my rocker? Hey, your code works, which is the only practical definition of 'good approach' > Somehow this > sort of manipulation seems like it should be part of the core of python in > the way that keys() and values() are already there. > This sounds like a nasty question, but think of it a an exercise. Exactly what kind of manipulation do you mean? Remember keys() and values() can be described exactly in one sentence only. Try to find the one-sentence description for your proposed extensions. You could then try building your own UserDict class that implements these manipulations as additional methods. Hope this helps, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From r.b.rigilink@chello.nl Tue Jun 12 14:21:05 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Tue, 12 Jun 2001 15:21:05 +0200 Subject: [Tutor] SubDictionaries or am I reinventing a wheel? References: Message-ID: <3B261741.23857E52@chello.nl> "Patrick K. O'Brien" wrote: > > D'oh!!! (Followed by a smack to the forehead.) > > Boy you nailed this one, Roeland! I knew I was overlooking something very > obvious (to everyone but me ). > > No, I did not consider using nested dictionaries. But you can bet I'll never > make that mistake again. Ouch! > > Your example of being able to do val = gmRecordTypes['CAL']['A'] was exactly > the kind of simple, elegant language feature I just knew had to be available > in python. I hope that explains the final question of my original post, > which in no way did I intend to sound "nasty". My apologies to anyone who > got that impression. > Misunderstanding ;) I didn't think your question was nasty, I thought you might take my question ('Exactly what kind of manipulation do you mean ?') as nasty, because you had actually given a pretty good explanation of what you meant. Anyway, glad to be of help, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From pobrien@orbtech.com Tue Jun 12 14:48:18 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Tue, 12 Jun 2001 08:48:18 -0500 Subject: [Tutor] SubDictionaries or am I reinventing a wheel? In-Reply-To: <3B261741.23857E52@chello.nl> Message-ID: Gotcha. My mistake. Going on too little sleep. The brain is a little slow this morning. Thanks again for the help. I really appreciate it. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: roeland [mailto:roeland]On Behalf Of Roeland Rengelink Sent: Tuesday, June 12, 2001 8:21 AM To: pobrien@orbtech.com Cc: Python Tutor Subject: Re: [Tutor] SubDictionaries or am I reinventing a wheel? "Patrick K. O'Brien" wrote: > > D'oh!!! (Followed by a smack to the forehead.) > > Boy you nailed this one, Roeland! I knew I was overlooking something very > obvious (to everyone but me ). > > No, I did not consider using nested dictionaries. But you can bet I'll never > make that mistake again. Ouch! > > Your example of being able to do val = gmRecordTypes['CAL']['A'] was exactly > the kind of simple, elegant language feature I just knew had to be available > in python. I hope that explains the final question of my original post, > which in no way did I intend to sound "nasty". My apologies to anyone who > got that impression. > Misunderstanding ;) I didn't think your question was nasty, I thought you might take my question ('Exactly what kind of manipulation do you mean ?') as nasty, because you had actually given a pretty good explanation of what you meant. Anyway, glad to be of help, Roeland -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 17:09:39 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 09:09:39 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! In-Reply-To: <200106121632.f5CGW5g07404@pop.nsacom.net> Message-ID: On Tue, 12 Jun 2001 kromag@nsacom.net wrote: > db=engine.OpenDatabase("\windows\desktop\terror.mdb") Here's the bug! When you put a backslash in a string, Python treats it as a special "escape" character. We can see how Python interpreted this particular string: ### >>> print "\windows\desktop\terror.mdb" \windows\desktop error.mdb ### It didn't find equivalent escape codes for '\w' or '\d', but '\t' matches with the 'tab' escape code. Assumedly, if engine.OpenDatabase can't find a file, it returns None, and that explains the error you're getting: ### AttributeError: 'None' object has no attribute 'Execute' ### The fix is to tell Python to treat the backslashes as regular characters. There are two main ways to do this: the first is to double up all the backslashes: db = engine.OpenDatabase("\\windows\\desktop\\terror.mdb") because the escape code for '\\' is the single backslash character. The other way is to use "raw strings", which are just strings which don't put any special meaning to the backslash: db = engine.OpenDatabase(r"\windows\desktop\terror.mdb") The leading 'r' in front tells Python to treat this particular string as a raw string. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 18:34:00 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 10:34:00 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! In-Reply-To: <200106121925.f5CJP2g20793@pop.nsacom.net> Message-ID: On Tue, 12 Jun 2001 kromag@nsacom.net wrote: > Daniel Yoo said: > > > On Tue, 12 Jun 2001 kromag@nsacom.net wrote: > > > > > db=engine.OpenDatabase("windowsdesktopterror.mdb") > > > > Here's the bug! When you put a backslash in a string, Python treats it as > > a special "escape" character. We can see how Python interpreted this > > particular string: > > Errr... Uuhhh... I always use double backslashes! Are you sure you > were using what I pasted in? :-) Oh my gosh. I'm sorry about that! I just woke up. I was looking at... ...wait a minute. > > ### > > >>> print "windowsdesktopterror.mdb" > > windowsdesktop error.mdb > > ## Hmmm... *laugh* > Traceback (most recent call last): > File "dbwrite.py", line 8, in ? > db=engine.OpenDatabase("\windows\desktop\terrorista.mdb") > File "", line 2, in OpenDatabase > pywintypes.com_error: (-2147352567, 'Exception occurred.', > (0, 'DAO.Workspace', "Couldn't find > file '\windows\desktop\terrorista.mdb'.", 'jeterr35.hlp', 5003024, - > 2146825264), None) > >Exit code: 1 Can you show us what your source code looks like now? With all these revisions, I'm having a difficult time remembering things. Talk to you later! From jarrett@ydyn.com Tue Jun 12 22:11:45 2001 From: jarrett@ydyn.com (W. Jarrett Campbell) Date: Tue, 12 Jun 2001 16:11:45 -0500 Subject: [Tutor] doc strings and structured text Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C0F35A.604CDC70 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0014_01C0F35A.604CDC70" ------=_NextPart_001_0014_01C0F35A.604CDC70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit In my new python adventure I've seen lots of reference to 'doc strings' and 'structured text'. I've even figured out how to generate some basic inline documentation using the ActiveState implementation of pydoc. However, I haven't been able to find a really good, tutorial level reference explaining doc strings and structured text. Does anyone have suggestions for some background reading on these topics. Thank you, Jarrett W. Jarrett Campbell, Ph.D. Member of the Technical Staff Yield Dynamics, Inc. 5838 Balcones Drive, Ste. 101 Austin, TX 78731 512.323.9149 office 512.257.9503 fax 512.415.1078 mobile jarrett@ydyn.com http://www.ydyn.com ------=_NextPart_001_0014_01C0F35A.604CDC70 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

In my = new python=20 adventure I've seen lots of reference to 'doc strings' and 'structured=20 text'.  I've even figured out how to generate some basic inline=20 documentation using the ActiveState implementation of pydoc.  = However, I=20 haven't been able to find a really good, tutorial level reference = explaining doc=20 strings and structured text.
 
Does = anyone have=20 suggestions for some background reading on these=20 topics.

Thank you,
 
Jarrett

 

W. Jarrett Campbell, = Ph.D.
Member=20 of the Technical Staff
Yield Dynamics, Inc.
5838 Balcones = Drive,=20 Ste. 101
Austin, TX 78731
512.323.9149 =20 office
512.257.9503  fax
512.415.1078  = mobile
jarrett@ydyn.com
http://www.ydyn.com
 
------=_NextPart_001_0014_01C0F35A.604CDC70-- ------=_NextPart_000_0013_01C0F35A.604CDC70 Content-Type: image/gif; name="signature.gif" Content-Transfer-Encoding: base64 Content-ID: <063081021@12062001-19aa> R0lGODlh+gBCALMAAAgICCQkJEVFRV5eXnNzc4iIiJycnK2trbW1tcXFxdbW1t7e3ufn5+/v7/f3 9////ywAAAAA+gBCAAAE/vDJSau9OOvNu/9gKI5kWS0GY65s675wLHNIAChzru9871sNwwBAcPyO yKRyGRQQBIuldEqtihjPRuFg7Xq/U4ZAoEAYGhkHooADu99wjyO7IGcYBpshzu/zHQUBCQ8GAkYX DAECCQZcfo+QVQgAgwwDbRYKAgMMDQRRkaGiPg5CEgwIhxViA2gFAmgjDAoEtQeqo7kYDrhgWQ8L ghdzAWgOA44gDgwHAwMGjQMIutQVDgoDRS29Kw1jRkIqQASOCa0h2NkK4g8JBLHVurQCAAbcIgsD oC0JATiWmCoc0AYoWQc8AT71EhMwXqQgTwLsaaHghotS9tqdAyKggIQa/uw4F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Yg4TD2mplX bDe+2zgnA1TilFlwE8EzSF87vAjhI1xDSALIU/L2W+G33atcHf6BjciABnfAKcQvuIqnwojiHDjg ahJBg2Tq0eIYqBjENY5BKTqSGmKwLMcp3hKOgfydgXzyco9yJ5FBcGMWL7kE+UjIVc1n1Se7QMXW 4vCTBUeUpjjZyia4ijcoDOYPBAqKHTVQmVsg5t6teaKCMl5F38yCq0CGzh3ox1bR59MD49kChRAM fMHcc4+WXiODP/7zCkqRk48q+qtqloCex/poDwiJhpWeQD98czWYZnpMrMTjo5EWz5+U99MuEI6W Q1ysTULJz6iOdUy1cRTvyfrWLBjI+JAialz7Wlb+eNInV/1rWcPtGbAttrJB4DAhLvvZcjAjtKdN bVxHAAAAOw== ------=_NextPart_000_0013_01C0F35A.604CDC70-- From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 22:54:06 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 14:54:06 -0700 (PDT) Subject: [Tutor] doc strings and structured text In-Reply-To: Message-ID: On Tue, 12 Jun 2001, W. Jarrett Campbell wrote: > In my new python adventure I've seen lots of reference to 'doc > strings' and 'structured text'. I've even figured out how to generate > some basic inline documentation using the ActiveState implementation > of pydoc. However, I haven't been able to find a really good, > tutorial level reference explaining doc strings and structured text. Hello! There's a good explanation on document strings "docstrings" here: http://www.onlamp.com/pub/a/python/2001/05/17/docstrings.html which should provide a high-level tutorial on what docstrings are about. Docstrings are small strings that we attach to functions: at the very beginning of a function definition, Python lets us stick in a string. For example: ### def invertDict(dict): """inverts a dictionary so that the keys become the values, and vice versa .""" newdict = {} for key, value in dict.items(): newdict[value] = key return newdict ### That multi-line string above is the docstring. What's neat is that we can look at this docstring later on if we want a small reminder of how things work: ### >>> print invertDict.__doc__ inverts a dictionary so that the keys become the values, and vice versa . >>> invertDict({1:'one', 2:'two', 3:'three'}) {'one': 1, 'two': 2, 'three': 3} ### Almost every function in Python has a docstring, which makes our life much easier. Docstrings can also be attached to classes. There's even a suggestion to allow docstrings to attach to pretty much everything, but I don't think that feature is implemented yet. How does this relate to the other topic of "structured text"? Structured text is an approach to let people use indentation in their docstrings as a way of structuring things. Think HTML, and you'll have the idea of StructuredText. The big difference is that StructuredText doesn't use tags at all. The ZopeBook (which is coming out by New Riders soon, yah!), is written in StructuredText, so you can take a look at an extended example of it here: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/zope-book/Book/README.txt?rev=1.2&content-type=text/plain (sorry about the long link) So the basic idea is to make it easy to write really elaborate docstrings without having to learn an HTML-like language. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 23:14:18 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 15:14:18 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! In-Reply-To: <200106122043.f5CKhZg08801@pop.nsacom.net> Message-ID: On Tue, 12 Jun 2001 kromag@nsacom.net wrote: > def Yoo(Need, Coffee): > headrush=open('/yoo/skull/caffeine_funnel.zap', 'r+') > write.headrush('%s', '%s')% ('cream', 'sugar') > time.sleep(0) > return: "to your keyboard" ^^^ Hmmm... there's a bug here --- the colon isn't necessary. The correction: ### return "to your keyboard" ### should fix things. Let's look at the rest of the program: > import string > import thread > > engine=win32com.client.Dispatch("DAO.DBEngine.35") > db=engine.OpenDatabase("\windows\desktop\terror.mdb") Ok, I'm not imagining things after all. *grin* There are backslashes on this line: can you double check? > One of the nice fellers over in db-sig said that the problem was that 'None' > is part of engine.OpenDatabase(). Sure enough: > > >>> print db > Traceback (innermost last): > File "", line 1, in ? > print db > [exception info cut] > Right there at the end, like an inflamed toe stands 'None'. Unfortunately I > am still too newbie to know whether this means that 'None' must be appeased > or if it can be bypassed. "None" is probably not a problem in this particular case; what this error means is that it wasn't able to establish the database connection properly. Once we get the connection working, you won't even need to worry about handling None, since it simply won't appear. If you fix the backslashing bug: db=engine.OpenDatabase(r"\windows\desktop\terror.mdb") then printing 'db' should be ok. Good luck! From dyoo@hkn.eecs.berkeley.edu Tue Jun 12 23:17:57 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 15:17:57 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! (fwd) Message-ID: Dear kromag, You message isn't being sent to tutor; strange! I see it in the carbon copy list, so I'm a little baffled. I'll forward it to the rest of the list. ---------- Forwarded message ---------- Date: Tue, 12 Jun 2001 13:43:35 -0700 (PDT) From: kromag@nsacom.net To: Daniel Yoo , Daniel Yoo , kromag@nsacom.net Cc: tutor@python.org Subject: Re: [Tutor] Threads.... Unhandle my Exception you Feind! Daniel Yoo said: def Yoo(Need, Coffee): headrush=open('/yoo/skull/caffeine_funnel.zap', 'r+') write.headrush('%s', '%s')% ('cream', 'sugar') time.sleep(0) return: "to your keyboard" It just won't run cleanly through the interpreter... :-) > > Can you show us what your source code looks like now? With all these > revisions, I'm having a difficult time remembering things. Certainly! -------------begin the bane of all threads---------- import win32com.client import random import time import string import thread engine=win32com.client.Dispatch("DAO.DBEngine.35") db=engine.OpenDatabase("\windows\desktop\terror.mdb") ## Function write() writes a list to the database def write(inputtage): ## I was just playin' with strings here... # time=inputtage[0] # data_string=inputtage[1] db.Execute("insert into data values(%f, '%s')" % inputtage) return 'ok' if __name__=='__main__': tik_tok=time.time() surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) the_madness=(tik_tok, surprize) thread.start_new_thread(write,(the_madness,)) -------------end the bane of all threads------------ One of the nice fellers over in db-sig said that the problem was that 'None' is part of engine.OpenDatabase(). Sure enough: >>> print db Traceback (innermost last): File "", line 1, in ? print db File "C:Python20win32comclientdynamic.py", line 165, in __str__ return str(self.__call__()) File "C:Python20win32comclientdynamic.py", line 165, in __str__ return str(self.__call__()) File "C:Python20win32comclientdynamic.py", line 150, in __call__ return self._get_good_object_(apply (self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None) com_error: (-2147352567, 'Exception occurred.', (0, 'DAO.TableDefs', 'Invalid argument.', 'jeterr35.hlp', 5003001, -2146825287), None) >>> Right there at the end, like an inflamed toe stands 'None'. Unfortunately I am still too newbie to know whether this means that 'None' must be appeased or if it can be bypassed. Is there a clean, cross-platform way to get rid of it? I haven't seen this sort of nonsense with psycopg and postgreSQ(uea)L yet, but I'll bet I will run on to similar things. I definitely want to get this through my head before I start fiddling with threading() and/or psycopg with it's cool persistent threads. It's getting hairy around here! :-) From israel@lith.com Wed Jun 13 02:28:22 2001 From: israel@lith.com (Israel Evans) Date: Tue, 12 Jun 2001 18:28:22 -0700 Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000? Message-ID: I have two problems here. The first is that I use windows 2000 at work( ok make that three problems ) and when I set a PYTHONPATH, things get screwy and tools like IDLE don't start up. I can still run some programs, but not all. If I delete PYTHONPATH everything works great, however setting PATH to accept the few exterior python directories that I've created doesn't seem to do anything and modules can't be found when I import them. The, now third problem is that I use windows98 at home ( four.... four problems!).. and I must ask you how in the bloody blue blazes does one set the environment variables in the config.sys or autoexec.bat/tsh thingamabobs anyway? Bamboozled and flummoxed through and through... ~Israel~ ------------------------------------------><-------------------------------- ------------ Finnegan's paper began with the electrifying sentence, "The average Canadian has one testicle, just like Adolph Hitler -- or, more precisely, the average Canadian has 0.96 testicles, an even sadder plight than Hitler's, if the average Anything actually existed." He then went on to demonstrate that the normal or average human lives in substandard housing in Asia, has 1.04 vaginas, cannot read or write, suffers from malnutrition and never heard of Silken Thomas Fitzgerald or Brian Boru. "The normal," he concluded "consists of a null set which nobody and nothing really fits." Timothy F.X. Finnegan founder of CSICON ------------------------------------------><-------------------------------- ------------ From dsh8290@rit.edu Wed Jun 13 03:02:30 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 12 Jun 2001 22:02:30 -0400 Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000? In-Reply-To: ; from israel@lith.com on Tue, Jun 12, 2001 at 06:28:22PM -0700 References: Message-ID: <20010612220230.C26826@harmony.cs.rit.edu> On Tue, Jun 12, 2001 at 06:28:22PM -0700, Israel Evans wrote: | | I have two problems here. | | The first is that I use windows 2000 at work( ok make that three problems ) | and when I set a PYTHONPATH, things get screwy and tools like IDLE don't | start up. I can still run some programs, but not all. If I delete | PYTHONPATH everything works great, however setting PATH to accept the few | exterior python directories that I've created doesn't seem to do anything | and modules can't be found when I import them. PYTHONPATH is analogous to CLASSPATH in Java. It is an environment variable that contains a path list of root directories for python modules/packages. I don't know why IDLE would get weird, unless maybe you left out something it needs. PATH is a shell variable that contains a path list to search for executables in. If you go to the shell prompt (C:\>) and type 'python', the shell will search through PATH until it finds python.exe. Same goes if you type 'foobar', though most likely you don't have 'foobar.exe' in PATH so it complains that it can't find it. | The, now third problem is that I use windows98 at home ( four.... four | problems!).. and I must ask you how in the bloody blue blazes does one set | the environment variables in the config.sys or autoexec.bat/tsh thingamabobs | anyway? Use a text editor (notepad will suffice though I prefer vim) and add the lines set PATH C:\python21;%PATH% set PYTHONPATH C:\python21\Lib;C:\your_python_modules to the bottom :-). -D From dsh8290@rit.edu Wed Jun 13 03:07:57 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 12 Jun 2001 22:07:57 -0400 Subject: [Tutor] Funny response Message-ID: <20010612220757.D26826@harmony.cs.rit.edu> Hi all. I just got an automated response from mailman after posting a reply to a question. It starts out with : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This automated response is sent to those of you new to the Tutor list, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LOL! I guess mailman got confused and thought I was new. :-) -D From mattvogel@hotmail.com Wed Jun 13 03:14:52 2001 From: mattvogel@hotmail.com (Matthew Vogel) Date: Wed, 13 Jun 2001 02:14:52 Subject: [Tutor] outputting HTML Message-ID:
Hi,
I am a newbie to python programming and i am having some trouble getting started in what i want to do.  I have written a C program that calls different functions in a library that i also wrote, in order to determine what records(name type and value) are stored in a given file. Now my problem is that i need to use python to output these values to an html file.
I know i need to use the os.popen() function to open the file that the user will enter as a command line argument when i run the main.py file ie (main.py filename).
The question is , once i run my c program from inside python to manipulate this data how do i output to html??
What functions are there in which i can output in html format, if i have already written an html page with headers and such????
any help would be appreciated greatly
thanks Matt
 


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

From rob@jam.rr.com Wed Jun 13 05:06:29 2001 From: rob@jam.rr.com (Rob Andrews) Date: Tue, 12 Jun 2001 23:06:29 -0500 Subject: [Tutor] outputting HTML References: Message-ID: <3B26E6C5.249A479A@jam.rr.com> Matthew Vogel wrote: > > Hi, > I am a newbie to python programming and i am having some trouble > getting started in what i want to do. I have written a C program that > calls different functions in a library that i also wrote, in order to > determine what records(name type and value) are stored in a given > file. Now my problem is that i need to use python to output these > values to an html file. > I know i need to use the os.popen() function to open the file that the > user will enter as a command line argument when i run the main.py file > ie (main.py filename). > The question is , once i run my c program from inside python to > manipulate this data how do i output to html?? > What functions are there in which i can output in html format, if i > have already written an html page with headers and such???? > any help would be appreciated greatly > thanks Matt > Sounds like fun! (heehee) Were you looking for info on generating the HTML, writing it to a file, or both? An example of a rudimentary web page maker from the Useless Python collection may be found here: http://www.lowerstandard.com/python/braindead.py You may find something of value in it. Happy Hacking, Rob As foretold by Nostradamus.... Useless Python! http://www.lowerstandard.com/python From wheelege@tsn.cc Wed Jun 13 06:35:06 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 13 Jun 2001 15:35:06 +1000 Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000? References: Message-ID: <00fc01c0f3ca$9ad0ea60$0200a8c0@ACE> > <...> > > The, now third problem is that I use windows98 at home ( four.... four > problems!).. and I must ask you how in the bloody blue blazes does one set > the environment variables in the config.sys or autoexec.bat/tsh thingamabobs > anyway? > tsh?? You should first check if your autoexec.bat and config.sys are being executed by going to Start->Run->msconfig, and verifying that the two boxes named 'Process xxx file' are checked. Then you can append what D-Man said...although of course I could be totally off the mark and in that case it would be wise to ignore me :) Glen. From dyoo@hkn.eecs.berkeley.edu Wed Jun 13 07:18:37 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 12 Jun 2001 23:18:37 -0700 (PDT) Subject: [Tutor] Grabbing the member functions of an instance? Message-ID: Out of curiosity, is there a better way of pulling out all the member functions from an instance? Here's what I have so far: ### ## Python must have something like this already... but I can't recall ## it at the moment. *sigh* def getBoundMembers(myinstance): """Returns all the member functions in a dictionary. Note: it does not yet look at inherited methods.""" dict = {} myclass = myinstance.__class__ for member_name in myclass.__dict__.keys(): dict[member_name] = getattr(myinstance, member_name) return dict ### I'm planning to use this function with a small toy game I'm making; as soon as I get it working, I'll be a happy person. *grin* Thanks for any help! From toodles@yifan.net Wed Jun 13 08:19:35 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Wed, 13 Jun 2001 15:19:35 +0800 Subject: FW: [Tutor] Uncallable class methods? Message-ID: Sorry Roeland! > -----Original Message----- > From: Andrew Wilkins [mailto:toodles@yifan.net] > Sent: Tuesday, 12 June 2001 10:12 PM > To: Roeland Rengelink > Subject: RE: [Tutor] Uncallable class methods? > > > > > > > Quick question about the following piece of code: > > > > > > >>> class X: > > > .. def y(): > > > .. print 'I am y of x.' > > > > > > Is there anyway that y can be invoked? My understanding is no, > > in which case, can anyone tell me why the interpreter doesn't > > complain about a class method being declared which does not have > > the minimum of one argument? > > > > > Okey dokey I just thought I'd give another answer to the > question, which also has the same useful nature of any of them *grin* > > import new > > class X: > def y(): > print 'I am y of x' > > func=new.function(X.y.func_code,X.y.func_globals) > > It doesn't look as pretty as Roeland's IMO, but I felt like > playing with the 'new' module =) > > Andrew Wilkins From r.b.rigilink@chello.nl Wed Jun 13 08:27:24 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Wed, 13 Jun 2001 09:27:24 +0200 Subject: [Tutor] Grabbing the member functions of an instance? References: Message-ID: <3B2715DC.C125BCCC@chello.nl> Hi Daniel, I wouldn't call it better. But this looks as base classes too, and only returns methods, not other objects. You also might want to have a look at the inspect module. Here goes: import types, new def method_dict(klass, inst): '''get a dict of all method_names:method in klass, bound to inst''' # We have to invert the look-up order, first look into bases right-to-left d = {} bases = list(klass.__bases__) bases.reverse() for baseklass in bases: d.update(method_dict(baseklass, inst)) # now look in the class itself for key, val in klass.__dict__.items(): if type(val) == types.FunctionType: d[key] = new.instancemethod(val, inst, klass) return d def methods(inst): '''returns dict of bound methods''' return method_dict(inst.__class__, inst) class X: def dox(self): print 'Hi' def doy(self): print 'Yo' class Y(X): def doy(self): print 'Ok' y = Y() print methods(y) print y.dox, y.doy Hope this helps, Roeland Daniel Yoo wrote: > > Out of curiosity, is there a better way of pulling out all the member > functions from an instance? Here's what I have so far: > > ### > ## Python must have something like this already... but I can't recall > ## it at the moment. *sigh* > def getBoundMembers(myinstance): > """Returns all the member functions in a dictionary. > > Note: it does not yet look at inherited methods.""" > dict = {} > myclass = myinstance.__class__ > for member_name in myclass.__dict__.keys(): > dict[member_name] = getattr(myinstance, member_name) > return dict > ### > > I'm planning to use this function with a small toy game I'm making; as > soon as I get it working, I'll be a happy person. *grin* > > Thanks for any help! > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From toodles@yifan.net Wed Jun 13 08:45:05 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Wed, 13 Jun 2001 15:45:05 +0800 Subject: [Tutor] Grabbing the member functions of an instance? In-Reply-To: Message-ID: Hi Daniel, > Out of curiosity, is there a better way of pulling out all the member > functions from an instance? Here's what I have so far: How about using inspect? (Are you using Python v 2.1?) I think someone recently spoke about inspect...in fact I thought it was you ^_^ I don't know a whole lot about inspect, but I'll give it a shot... import inspect def getBoundMembers(myinstance): dict={} members=inspect.getmembers(myinstance.__class__) for member in members: if inspect.ismethod(member[1]): dict[member[0]]=member[1] return dict Actually now that I look at it, it is more work *grin* Andrew Wilkins > > ### > ## Python must have something like this already... but I can't recall > ## it at the moment. *sigh* > def getBoundMembers(myinstance): > """Returns all the member functions in a dictionary. > > Note: it does not yet look at inherited methods.""" > dict = {} > myclass = myinstance.__class__ > for member_name in myclass.__dict__.keys(): > dict[member_name] = getattr(myinstance, member_name) > return dict > ### > > I'm planning to use this function with a small toy game I'm making; as > soon as I get it working, I'll be a happy person. *grin* > > Thanks for any help! > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From hanna@chagford.com Wed Jun 13 20:26:26 2001 From: hanna@chagford.com (Hanna Joo) Date: Wed, 13 Jun 2001 12:26:26 -0700 Subject: [Tutor] Threads threads threads gaaahgh (foaming at the mouth) Message-ID: <003801c0f43e$c1e16de0$0100007f@localdomain> Big thanks to those who helped me. This is the updated version of the producer consumer thing. The problem now is getting 'notify' and 'wait' working. The reference book says that I those are the methods of condition variables (boohoohoo english is not even my first language and people do this to me). I went through chapters on threads again, but I still don't really get it. help please T_____T (tears streaming down). TIA import threading from random import randint class Soup: def __init__(self): self.next = 0 self.isFull = 0 self.isEmpty = 1 self.buff = "" def eat(self): while self.isEmpty: try : wait() ######### except: pass self.next = self.next - 1 if not self.next: self.isEmpty = 1 self.isFull = 0 notify() ########=======> how to do this? return self.buff[next] def add(self,c): while self.isFull: try: wait() ########===========> this as well except: pass self.buff = self.buff[:self.next]+c+self.buff[self.next:] self.next += 1 if self.next == len(self.buff): self.isFull= 1 self.isEmpty = 0 notify() ##### class Consumer: def __init__(self,soup): self.soup = soup def run(self): for i in range(10) : c = self.soup.eat(); print "Ate a letter "+c try: sleep(randint(1,3)) except: pass class Producer: def __init__(self,soup): self.soup = soup self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def run(self): for i in range(10): c = self.alphabet[randint(1,27)] self.soup.add(c); print "Added "+c+" to the soup" try: sleep(randint(1,3)) except: pass def main(): s = Soup() p1 = Producer(s) s1 = Consumer(s) t1 = threading.Thread(target=p1.run) t2 = threading.Thread(target=s1.run) t1.start() t2.start() try : t1.join() t2.join() except: print "The producer or consumer thread's join() was interrupted..." if __name__ == '__main__': main() From kromag@nsacom.net Wed Jun 13 16:02:39 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Wed, 13 Jun 2001 08:02:39 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! Message-ID: <200106131502.f5DF2dg12285@pop.nsacom.net> > > Let's look at the rest of the program: > > > import string > > import thread > > > > engine=win32com.client.Dispatch("DAO.DBEngine.35") > > db=engine.OpenDatabase("windowsdesktopterror.mdb") > > Ok, I'm not imagining things after all. *grin* There are backslashes on > this line: can you double check? But, but, but..... Really! I am looking at the code I pasted in! It has double backslashes! What manner of madness? Surely your mail agent doesn't parse them into links? Anyway, I tried it with the r"pathtofile" method and got the same error: >pythonw -u dbwrong.py Unhandled exception in thread: Traceback (most recent call last): File "dbwrong.py", line 15, in write db.Execute("insert into data values(%f, '%s')" % inputtage) AttributeError: 'None' object has no attribute 'Execute' >Exit code: 0 Ah well. I am going to not think about it for a week. That has traditionally been the length of time it takes for the answer to coalesce out of the aether! :-) Thanks for your efforts! d From pobrien@orbtech.com Wed Jun 13 15:12:00 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 13 Jun 2001 09:12:00 -0500 Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000? In-Reply-To: <20010612220230.C26826@harmony.cs.rit.edu> Message-ID: This might seem like nitpicking, but it isn't necessary to add Lib to your PYTHONPATH. At least not with version 2.1, because python adds lib (and several other directories) automatically. Here is a copy of my entire autoexec.bat on my Win98SE machine: SET PATH=C:\Python21 SET PYTHONPATH=C:\My Documents\pobrien\Code SET PYTHONSTARTUP=C:\My Documents\pobrien\.pythonrc.py --- And here is an interactive session showing the resulting python path (sys.path): Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import sys >>> sys.path ['C:\\My Documents\\pobrien\\Code', 'C:\\PYTHON21\\Tools\\idle', 'c:\\my documents\\pobrien\\code', 'c:\\python21\\win32', 'c:\\python21\\win32\\lib', 'c:\\python21', 'c:\\python21\\pythonwin', 'c:\\python21\\dlls', 'c:\\python21\\lib', 'c:\\python21\\lib\\plat-win', 'c:\\python21\\lib\\lib-tk', 'c:\\python21\\numeric'] >>> --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of D-Man Sent: Tuesday, June 12, 2001 9:03 PM To: 'Tutor@python.org' Subject: Re: [tutor] PATH vs PYTHONPATH on win98 and win2000? Use a text editor (notepad will suffice though I prefer vim) and add the lines set PATH C:\python21;%PATH% set PYTHONPATH C:\python21\Lib;C:\your_python_modules to the bottom :-). -D _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From allan.crooks@btinternet.com Wed Jun 13 17:13:14 2001 From: allan.crooks@btinternet.com (Allan Crooks) Date: Wed, 13 Jun 2001 17:13:14 +0100 Subject: [Tutor] Threads threads threads gaaahgh (foaming at the mouth) Message-ID: After having a quick look at the threading library, I started adjusting your code in quite a few ways. First of all, here's the code you submitted: > import threading > from random import randint > > > class Soup: > > def __init__(self): > self.next = 0 > self.isFull = 0 > self.isEmpty = 1 > self.buff = "" > > def eat(self): > > while self.isEmpty: > try : wait() ######### > except: pass > > self.next = self.next - 1 > > if not self.next: > self.isEmpty = 1 > > self.isFull = 0 > notify() ########=======> how to do this? > > return self.buff[next] > > > def add(self,c): > while self.isFull: > try: wait() ########===========> this as well > except: pass > self.buff = self.buff[:self.next]+c+self.buff[self.next:] > self.next += 1 > > if self.next == len(self.buff): > self.isFull= 1 > self.isEmpty = 0 > notify() ##### > > class Consumer: > > > def __init__(self,soup): > self.soup = soup > > def run(self): > > for i in range(10) : > c = self.soup.eat(); > print "Ate a letter "+c > > try: > sleep(randint(1,3)) > > except: > pass > > class Producer: > > > def __init__(self,soup): > self.soup = soup > self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > > def run(self): > > for i in range(10): > c = self.alphabet[randint(1,27)] > self.soup.add(c); > print "Added "+c+" to the soup" > try: sleep(randint(1,3)) > except: pass > > > def main(): > > s = Soup() > > p1 = Producer(s) > s1 = Consumer(s) > > t1 = threading.Thread(target=p1.run) > t2 = threading.Thread(target=s1.run) > > t1.start() > t2.start() > > try : > > t1.join() > t2.join() > > except: > > print "The producer or consumer thread's join() was interrupted..." > > > > if __name__ == '__main__': > main() > Here's the modified code. The comments (#01, #02 etc.) are used as markers, so I can illustrate how your code has been modified. import threading from time import sleep #01 from random import randrange #02 class Soup: def __init__(self): self.next = 0 self.isFull = 0 self.isEmpty = 1 self.buff = "" self.lock = threading.Condition() #03 def eat(self): self.lock.acquire() #04 while self.isEmpty: self.lock.wait() #05 self.next = self.next - 1 if not self.next: self.isEmpty = 1 self.isFull = 0 self.lock.notify() #06 self.lock.release() #07 return self.buff[self.next] #08 def add(self,c): self.lock.acquire() #09 while self.isFull: self.lock.wait() #10 self.buff = self.buff[:self.next]+c+self.buff[self.next:] self.next += 1 if self.next == len(self.buff): self.isFull = 1 self.isEmpty = 0 self.lock.notify() #11 self.lock.release() #12 class Consumer: def __init__(self,soup): self.soup = soup def run(self): for i in range(10) : c = self.soup.eat(); print "Ate a letter", c #13 sleep(randrange(1,5)) #14 class Producer: def __init__(self,soup): self.soup = soup self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def run(self): for i in range(10): c = self.alphabet[randrange(26)] #15 self.soup.add(c); print "Added", c, "to the soup" #16 sleep(randrange(1,3)) #17 def main(): s = Soup() p1 = Producer(s) s1 = Consumer(s) t1 = threading.Thread(target=p1.run) t2 = threading.Thread(target=s1.run) t1.start() t2.start() try : t1.join() t2.join() except: print "The producer or consumer thread's join() was interrupted..." if __name__ == '__main__': main() -------------- OK, so here's an explanation of the changes. #01: You forgot to import sleep from the time module. #02: We're using randrange instead of randint, because randrange(x,y) will return a number between x (inclusive) and y (exclusive). randint returns a number between x (inclusive) and y (inclusive). It doesn't make much of a difference, it's just what I've chosen to use. #03: We're using "condition" objects to deal with locking and unlocking. We need to use these so we can do notify() and wait(). #04: Here we've "acquired" the lock. We need to do this before we can do "wait" or "notify" #05: Now we're using the condition object and waiting on it. #06: This is the notify that you wanted to put in the code, and we're just invoking the method on the condition object. #07: We must remember to release the lock once we have finished. #08: Your code said "return self.buff[next]". What we meant was: "return self.buff[self.next]". #09: Same as #04. #10: Same as #05. #11: Same as #06. #12: Same as #07. #13: Doesn't do anything different, but it looks nicer than "Ate a letter "+c. :) #14: We're just using the randrange method. You may have noticed I adjusted the parameters for randrange, that's because I was just testing with different parameters. #15: The initial version was more complicated. First of all, the code assumed that the string indexed from 1 (it doesn't). Secondly, changing 1, 27 to 0, 26 still didn't work, because randint may pick a number from 0 to 26, including 26 itself (which is an invalid index). So we can change it either to randint(0,25) or randrange(0,26). I've chosen the randrange option. #16: Same as #13, it looks nicer. :) #17: Just using randrange again. Now having changed that code, I get this: >>> soup.main() Ate a letter Y Added Y to the soup Ate a letter R Added R to the soup Added M to the soup Added X to the soup Ate a letter X Added A to the soup Added F to the soup Ate a letter F Added S to the soup Added A to the soup Added G to the soup Ate a letter G Added P to the soup Ate a letter P Ate a letter A Ate a letter S Ate a letter A Ate a letter M The code takes several seconds to execute. It seems to work properly. There are a few more things I feel I should point out about your code for the sake of improvements: 1) You don't need to use a "next" variable, you can simply use the len function. 2) I think it'd be easier and nicer to write if you used a list object for a buffer instead of a string. That way, the line in the eat function: return self.buff[self.next] would become: return self.buff.pop() And the line in the add function: self.buff = self.buff[:self.next]+c+self.buff[self.next:] would become: self.buff.append(c) 3) Your code had too many "excepts" in it. That in itself is not a bad thing, but you were using "except:" rather than catching any specific errors (e.g. "except: (AttributeError, IndexError), e"). That's definitely something you should aim to change in your programs in the future. For example, your code in the run method of Consumer had these lines in it: > try: > sleep(randint(1,3)) > > except: > pass Invoking the sleep function doesn't actually raise any exception, but in the code supplied, sleep was undefined (because it wasn't imported). But because you use caught all types of exceptions (including NameErrors), it was harder to track down why no thread seemed to be waiting. If you want to catch a particular exception, you should explicitly state their types, otherwise errors which you would want to get through will not. HTH, Allan. From DavidCraig@PIA.CA.GOV Wed Jun 13 18:01:02 2001 From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV) Date: Wed, 13 Jun 2001 10:01:02 -0700 Subject: [Tutor] Python for Web Applications - Off Topic Message-ID: This came out this morning from Open Source - Interesting ONE SIZE FITS MOST Posted at June 8, 2001 01:01 PM PST Pacific THIS WEEK I finally make good on my promise to take a closer look at Python for building Web applications. Python is a Javalike language in some of the most important respects. It is byte-compiled and therefore platform-neutral. It sports automatic garbage collection, which means you won't have to worry about cleaning up after Python objects when you're done with them. And it handles exceptions well, enabling you to make your programs more robust. Unlike Java, Python does not need type declarations, which means a variable becomes a string type simply by setting it to a string value. That is one reason it seems to take a lot less work to crank out a quick and dirty application in Python than it does using Java. Python has a long list of available expansion modules to give your Python Web application access to LDAP, IMAP4 (Internet Messaging Access Protocol 4), POP (Post Office Protocol), SMTP, NNTP (Network News Transfer Protocol), among other Internet resources. There is also a number of generic database interfaces to popular SQL servers. If Web applications aren't your thing, you can still use Python to create anything from simple command-line scripts to full-blown graphical applications using the Troll Tech Qt GUI toolkit. You can use several methods to add Python capability to your Web server, and they are not necessarily mutually exclusive. I have set up my servers to run Python in a number of different ways, according to need. The simplest and most efficient way to add Python to Apache is to use the mod_python interface, available at www.modpython.org. When you use this module, you generally publish information to the browser by using the "req.write()" command. This Apache module isn't terribly useful by itself, but it comes with a mod_python publisher module that makes it much easier to use Python to write Web applications. When you configure Apache to use the mod_python publisher, you can execute Python functions by pointing to the Python application, followed by the function you want to run. For example, if you want to run the "say_hello" function in the "welcome.py" program, point your browser to "http://somesite.domain/welcome/say_hello." The only drawback to the publisher module is that it writes information to the browser based only on the information a function returns. This means that you have to create a Web page by assembling a long string or an array and then passing it to the browser all at once at the end of the function. This approach can work to your advantage, depending on the type of application you are building. If you must assemble each page by combining parts into a whole, you will probably spend more time thinking about which parts to create. You are likely to think through how you should break up your Web site content so that you end up with a site that doesn't break the first time you need to add a module or change the appearance of a page. Of course, that doesn't mean you can't be sloppy if you want to be. If you're spoiled on the freedom afforded by a Web language such as PHP (Hypertext PreProcessor, www.php4.org), you can always use PSP. I used PSP via a toolkit known as Webware for Python (webware.sourceforge.net). PSP uses almost the same syntax as Java Server Pages (JSP), so it's easy to bounce between the two if you're used to one or the other. At the other extreme, the WebKit portion of Webware for Python really carries Python into the big leagues for Web application development. WebKit includes a multithreaded application server that runs alongside Apache. The WebKit server serves up the Python applications more intelligently than mod_python alone or the mod_python publisher. In fact, although WebKit can use mod_python as its default Python extension to Apache, WebKit comes with its own Apache module in case you don't want or need mod_python. If you are serious about using Python to develop for the Web, I strongly recommend that you look at WebKit and the sample applications. The samples aren't pretty, but they demonstrate the power of Python's object-oriented nature when it comes to building the framework for a Web application and then extending it as needed. Be sure to visit the online version of this column for examples of Python Server Pages, mod_python, and the mod_python publisher if you want a closer look. I also will be publishing detailed examples on VarLinux.org (www.varlinux.org). Finally, some readers have pointed me to Ruby, a Pythonlike language which is yet another alternative. I haven't yet had the time to check it out, but when I do I'll let you know what I find. PSP example Here is an example of how to Python within a server page, my least favorite way to use Python, I might add. This file could be called "welcome.psp," which has the .psp extension to alert Apache that this is a Python Server Page. For a sample Apache configuration to run PSP, see the last example at the bottom. Welcome <% title = "

Welcome to the world of Python

" greeting = "If you lived here, you'd be home by now" res.write(title) res.write("

")res.write(greeting) %> mod_python example Here is an example of using Python with the simplest mod_python approach. You would create a file called "welcome.py" with the following content. from mod_python import apache def handler(req): title = "

Welcome to the world of mod_python

"greeting = "If you lived here, etc." req.content_type = "text/html"req.send_http_header() req.write(title) req.write(greeting) return apache.OK Then you must create an entry for this file in your Apache configuration file "httpd.conf". That entry might look something like the following, assuming you have named the above file "welcome.py" and put it in a directory called "/python." Note that it is the "PythonHandler" statement that points to the welcome.py file (the ".py" extension is not needed here since it is assumed). AddHandler python-program .py PythonHandler welcome The browser accesses this Python file with a URL such as "http://somesite.domain/welcome." The mod_python module automatically executes the handler function for the file "welcome.py." In most cases, this isn't a terribly useful means of using Python for Web applications because there can be only one Python handler file for each directory. A reasonable application would span many directories, each with its own handler. mod_python example using Publisher Handler The mod_python module comes with a Publisher Handler that allows you to create Web applications using fewer Python files and directories. You can create many functions for your Python programs, and you can reference these functions directly through URLs. For example, if you want to execute the "say_hello" function in the "welcome.py" program, you would use the URL "http://somesite.domain/welcome/say_hello." Use the URL "http://somesite.domain/welcome/say_goodbye" to access the "say_goodbye" function. For the simplest configuration, just add lines such as these to your Apache configuration file to activate the publisher. AddHandler python-program .py PythonHandler mod_python.publisher Then you can create "welcome.py" to include the following. def say_goodbye():s = "

Thanks for visiting!

" return s def say_hello(): h1open = "

" h1close = "

" s = h1open + "Welcome to mod_python publisher." + h1close return s The mod_python publisher sends text, HTML, or whatever you choose to a browser depending on what a function returns. In the example above, each function returns string "s," which contains different text depending on the function. Combinations Here is a sample way to configure Apache if you want to use Python according to your varying needs. This configuration allows you to use mod_python to run either mod_python publisher-based applications, Python Server Pages, or the more sophisticated Webware applications via WebKit. You should adjust the configuration to work with the way you have installed software on your particular server. My test system is Debian-based, which is why the Web data is placed under the "/var/www" directory. AddHandler python-program .psp PythonPath "sys.path+['/var/www/Webware/WebKit']" PythonHandler ModPythonAdapter::pspHandler PythonDebug On Alias /python/ /var/www/python/ AddHandler python-program .py SetHandler python-program PythonPath "sys.path+['/var/www/python', '/python']" PythonHandler mod_python.publisher Options +ExecCGI PythonDebug On Alias /webware/ /var/www/Webware/WebKit/ AddHandler python-program .py SetHandler python-program # add the directory that contains ModPythonAdapter.py PythonPath "sys.path+['/var/www/Webware/WebKit']" PythonHandler ModPythonAdapter Options +ExecCGI PythonDebug On Nick Petreley is the founding editor of VarLinux.org (www.varlinux.org) and LinuxWorld. Reach him at nicholas@petreley.com. D. H. Craig, CSM From pdiaz88@terra.es Wed Jun 13 22:42:50 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Wed, 13 Jun 2001 21:42:50 +0000 Subject: [Tutor] Python for Web Applications - Off Topic In-Reply-To: References: Message-ID: <01061321425000.06281@duero> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Funny he/she didn't Zope, right? Cheers Pedro On Wednesday 13 June 2001 17:01, DavidCraig@PIA.CA.GOV wrote: > This came out this morning from Open Source - Interesting > > ONE SIZE FITS MOST > > Posted at June 8, 2001 01:01 PM PST Pacific > > > THIS WEEK I finally make good on my promise to take a > closer look at Python for building Web applications. > > Python is a Javalike language in some of the most > important respects. It is byte-compiled and therefore > platform-neutral. It sports automatic garbage > collection, which means you won't have to worry about > cleaning up after Python objects when you're done with > them. And it handles exceptions well, enabling you to > make your programs more robust. > > Unlike Java, Python does not need type declarations, > which means a variable becomes a string type simply by > setting it to a string value. That is one reason it > seems to take a lot less work to crank out a quick and > dirty application in Python than it does using Java. > > Python has a long list of available expansion modules > to give your Python Web application access to LDAP, > IMAP4 (Internet Messaging Access Protocol 4), POP > (Post Office Protocol), SMTP, NNTP (Network News > Transfer Protocol), among other Internet resources. > There is also a number of generic database interfaces > to popular SQL servers. If Web applications aren't > your thing, you can still use Python to create > anything from simple command-line scripts to > full-blown graphical applications using the Troll Tech > Qt GUI toolkit. > > You can use several methods to add Python capability to > your Web server, and they are not necessarily mutually > exclusive. I have set up my servers to run Python in a > number of different ways, according to need. > > The simplest and most efficient way to add Python to > Apache is to use the mod_python interface, available > at www.modpython.org. When you use this module, you > generally publish information to the browser by using > the "req.write()" command. > > This Apache module isn't terribly useful by itself, but > it comes with a mod_python publisher module that makes > it much easier to use Python to write Web > applications. When you configure Apache to use the > mod_python publisher, you can execute Python functions > by pointing to the Python application, followed by the > function you want to run. For example, if you want to > run the "say_hello" function in the "welcome.py" > program, point your browser to > "http://somesite.domain/welcome/say_hello." > > The only drawback to the publisher module is that it > writes information to the browser based only on the > information a function returns. This means that you > have to create a Web page by assembling a long string > or an array and then passing it to the browser all at > once at the end of the function. > > This approach can work to your advantage, depending on > the type of application you are building. If you must > assemble each page by combining parts into a whole, > you will probably spend more time thinking about which > parts to create. You are likely to think through how > you should break up your Web site content so that you > end up with a site that doesn't break the first time > you need to add a module or change the appearance of a > page. > > Of course, that doesn't mean you can't be sloppy if you > want to be. If you're spoiled on the freedom afforded > by a Web language such as PHP (Hypertext PreProcessor, > www.php4.org), you can always use PSP. I used PSP via > a toolkit known as Webware for Python > (webware.sourceforge.net). PSP uses almost the same > syntax as Java Server Pages (JSP), so it's easy to > bounce between the two if you're used to one or the other. > > At the other extreme, the WebKit portion of Webware for > Python really carries Python into the big leagues for > Web application development. WebKit includes a > multithreaded application server that runs alongside > Apache. The WebKit server serves up the Python > applications more intelligently than mod_python alone > or the mod_python publisher. In fact, although WebKit > can use mod_python as its default Python extension to > Apache, WebKit comes with its own Apache module in > case you don't want or need mod_python. > > If you are serious about using Python to develop for > the Web, I strongly recommend that you look at WebKit > and the sample applications. The samples aren't > pretty, but they demonstrate the power of Python's > object-oriented nature when it comes to building the > framework for a Web application and then extending it > as needed. > > Be sure to visit the online version of this column for > examples of Python Server Pages, mod_python, and the > mod_python publisher if you want a closer look. I also > will be publishing detailed examples on VarLinux.org > (www.varlinux.org). > > Finally, some readers have pointed me to Ruby, a > Pythonlike language which is yet another alternative. > I haven't yet had the time to check it out, but when I > do I'll let you know what I find. > > PSP example > > Here is an example of how to Python within a server > page, my least favorite way to use Python, I might > add. This file could be called "welcome.psp," which > has the .psp extension to alert Apache that this is a > Python Server Page. For a sample Apache configuration > to run PSP, see the last example at the bottom. > > Welcome <% > title = "

Welcome to the world of Python

" > greeting = "If you lived here, you'd be home by now" > res.write(title) res.write("

")res.write(greeting) > %> > > > > mod_python example > > Here is an example of using Python with the simplest > mod_python approach. You would create a file called > "welcome.py" with the following content. > > from mod_python import apache > > def handler(req): title = "

Welcome to the world of > mod_python

"greeting = "If you lived here, etc." > > > > req.content_type = "text/html"req.send_http_header() > req.write(title) req.write(greeting) > > > > return apache.OK > > Then you must create an entry for this file in your > Apache configuration file "httpd.conf". That entry > might look something like the following, assuming you > have named the above file "welcome.py" and put it in a > directory called "/python." Note that it is the > "PythonHandler" statement that points to the > welcome.py file (the ".py" extension is not needed > here since it is assumed). > > AddHandler python-program .py > PythonHandler welcome > > > > The browser accesses this Python file with a URL such > as "http://somesite.domain/welcome." The mod_python > module automatically executes the handler function for > the file "welcome.py." > > In most cases, this isn't a terribly useful means of > using Python for Web applications because there can be > only one Python handler file for each directory. A > reasonable application would span many directories, > each with its own handler. > > mod_python example using Publisher Handler > > The mod_python module comes with a Publisher Handler > that allows you to create Web applications using fewer > Python files and directories. You can create many > functions for your Python programs, and you can > reference these functions directly through URLs. For > example, if you want to execute the "say_hello" > function in the "welcome.py" program, you would use > the URL "http://somesite.domain/welcome/say_hello." > Use the URL > "http://somesite.domain/welcome/say_goodbye" to access > the "say_goodbye" function. > > For the simplest configuration, just add lines such as > these to your Apache configuration file to activate > the publisher. > > AddHandler python-program .py PythonHandler > mod_python.publisher > > > > Then you can create "welcome.py" to include the > following. > > > > def say_goodbye():s = "

Thanks for visiting!

" > return s > > > > def say_hello(): h1open = "

" h1close = "

" s = > h1open + "Welcome to mod_python publisher." + h1close > return s > > > > The mod_python publisher sends text, HTML, or whatever > you choose to a browser depending on what a function > returns. In the example above, each function returns > string "s," which contains different text depending on > the function. > > Combinations > > Here is a sample way to configure Apache if you want to > use Python according to your varying needs. This > configuration allows you to use mod_python to run > either mod_python publisher-based applications, Python > Server Pages, or the more sophisticated Webware > applications via WebKit. You should adjust the > configuration to work with the way you have installed > software on your particular server. My test system is > Debian-based, which is why the Web data is placed > under the "/var/www" directory. > > AddHandler python-program .psp > PythonPath "sys.path+['/var/www/Webware/WebKit']" > PythonHandler ModPythonAdapter::pspHandler PythonDebug > On > > > > Alias /python/ /var/www/python/ /python>AddHandler python-program .py SetHandler > python-program PythonPath > "sys.path+['/var/www/python', '/python']" > PythonHandler mod_python.publisher Options +ExecCGI > PythonDebug On > > > > Alias /webware/ /var/www/Webware/WebKit/ /webware> AddHandler python-program .py SetHandler > python-program # add the directory that contains > ModPythonAdapter.py PythonPath > "sys.path+['/var/www/Webware/WebKit']" PythonHandler > ModPythonAdapter Options +ExecCGI PythonDebug On > > > Nick Petreley is the founding editor of VarLinux.org > (www.varlinux.org) and LinuxWorld. Reach him at > nicholas@petreley.com. > D. H. Craig, CSM > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor - -- /* * Pedro Diaz Jimenez * pdiaz88@terra.es * pdiaz@acm.asoc.fi.upm.es * * Wanna see how 100000! looks like?: * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000 * * La sabiduria me persigue, pero yo soy mas rapido * * "Las artes marciales son parte de una filosofía, * no deben ser consideradas un arma. Y por eso, * recuerda: No hay nada como un buen revolver" * Les Luthiers, Iniciacion a las Artes Marciales * */ Random quote: - ------------- ROMEO: Courage, man; the hurt cannot be much. MERCUTIO: No, 'tis not so deep as a well, nor so wide as a church-door; but 'tis enough, 'twill serve. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7J95gnu53feEYxlERAo3EAJ9GFAhrJ79LEN+G8bEBWi8Xd42VCQCdFWk8 kGwLSWa+83hLNo1TPO/brTk= =iiGY -----END PGP SIGNATURE----- From hall@ouhep1.nhn.ou.edu Wed Jun 13 21:24:10 2001 From: hall@ouhep1.nhn.ou.edu (Isaac Hall) Date: Wed, 13 Jun 2001 15:24:10 -0500 Subject: [Tutor] (no subject) Message-ID: <01061315265100.26218@ouhep1> hello all (again) I would like to pose a (hopefully) quick and easy question that is confounding me. in a program I am trying to write, it has become apparent to me that I need to create my own widget to place in a Tk window to accomplish what I need. How can I do this??? if I am being to vague, let me know and I will clarify. thanks Ike From mascher@crg.ha.nw.schule.de Wed Jun 13 21:45:11 2001 From: mascher@crg.ha.nw.schule.de (Christian Mascher) Date: Wed, 13 Jun 2001 22:45:11 +0200 Subject: [Tutor] PYTHONPATH: where to set on Win9x Message-ID: <3B27D0D7.30DB0E5@gmx.de> Hello everyone, I've been following the recent postings on implementing a startup-configuration of some sorts, perhaps loading some modules (pydoc) or setting up the path to arbitrary extra module-directories (my private modules). As far as I understood the matter, the module-search-path (shown with 'sys.path') where Python looks for and is able to find modules must (?) be set via the environment variable PYTHONPATH. But that doesn't seem to be the whole story on windows, because I can run python and import all standard modules with no explicit PYTHONPATH set in the environment. (During installation the necessary paths must have been hardwired into the registry. For the same reason I can start idle by "executing" idle.pyw from the shell (explorer) right?). So I guess I only have to use PYTHONPATH for having my personal directories turn up in sys.path, is that right? Meaning I only need to put set PYTHONPATH=d:\mypython in autoexec.bat to include that directory. It works, but is it "the right way" or did I miss a point? By the way, is the global autoexec.bat really the best place for putting this? Normally, when I use a console-started compiler (like javac for instance), I have an extra .bat-script setting the appropriate environment-variables only when opening the shell (DOS-box) dedicated to Java or whatever. So it is possible to add environment variables later. Could/should this be done for the python shell as well? One could of course append to sys.path in a standard startupscript, but then I have to set PYTHONSTARUP first, yes? Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo just sorted out, but I'm really still confused about the issue. Thanks in advance, Christian From rob@jam.rr.com Wed Jun 13 21:52:48 2001 From: rob@jam.rr.com (Rob Andrews) Date: Wed, 13 Jun 2001 15:52:48 -0500 Subject: [Tutor] (no subject) References: <01061315265100.26218@ouhep1> Message-ID: <002801c0f44a$da32e660$de00a8c0@planhouse5> ----- Original Message ----- From: "Isaac Hall" To: Sent: Wednesday, June 13, 2001 3:24 PM Subject: [Tutor] (no subject) > hello all (again) > I would like to pose a (hopefully) quick and easy question that is confounding > me. in a program I am trying to write, it has become apparent to me that I > need to create my own widget to place in a Tk window to accomplish what I need. > How can I do this??? if I am being to vague, let me know and I will clarify. > > thanks > Ike > If you can provide a little more detail about your challenge, it would help. For instance, what is it that you are trying to do. There are some really interesting widgets available out there already. Can you show any code that is tripping you in particular? Rob Useless Python It's not just for breakfast anymore! http://www.lowerstandard.com/python/index.html From hall@ouhep1.nhn.ou.edu Wed Jun 13 21:56:35 2001 From: hall@ouhep1.nhn.ou.edu (Isaac Hall) Date: Wed, 13 Jun 2001 15:56:35 -0500 Subject: [Tutor] (no subject) In-Reply-To: <002801c0f44a$da32e660$de00a8c0@planhouse5> References: <01061315265100.26218@ouhep1> <002801c0f44a$da32e660$de00a8c0@planhouse5> Message-ID: <01061316152200.27433@ouhep1> --Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD Content-Type: text/plain Content-Transfer-Encoding: 8bit On Wed, 13 Jun 2001, Rob Andrews wrote: > ----- Original Message ----- > From: "Isaac Hall" > To: > Sent: Wednesday, June 13, 2001 3:24 PM > Subject: [Tutor] (no subject) > > > > hello all (again) > > I would like to pose a (hopefully) quick and easy question that is > confounding > > me. in a program I am trying to write, it has become apparent to me that > I > > need to create my own widget to place in a Tk window to accomplish what I > need. > > How can I do this??? if I am being to vague, let me know and I will > clarify. > > > > thanks > > Ike > > > If you can provide a little more detail about your challenge, it would help. > For instance, what is it that you are trying to do. There are some really > interesting widgets available out there already. Can you show any code that > is tripping you in particular? > > Rob > > Useless Python > It's not just for breakfast anymore! > http://www.lowerstandard.com/python/index.html yes I can, specifically Im trying to put several pie charts in a window, that can be sized and moved about as the user wants. (at least by changing a value or two) as of now, I can do this by defining a function that makes the piechart on a canvas which is put in a frame, which is then put in a grid by the grid geometry manager. however, the powers that be tell me it would be fantastic if I could do this by skipping the nasty canvas to frame thing altogether, and create a piechart widget (or class or something like that), which I could directly throw into the geometry manager, and hopefully create more ease in allowing the user to specify location, size, etc. this is where Im stuck. Ive attached a sample of what it is Im doing, which works just fine, but they just want no canvases...... --Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD Content-Type: text/x-java; name="tester.py" Content-Transfer-Encoding: base64 Content-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cm93M1tpXStyb3c0W2ldK3JvdzVbaV0rcm93NltpXStyb3c3W2ldK3JvdzhbaV0pCglpID0g aSsxCgpsYWJlbDkgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSA5IChzdW0gb24gZWFjaCBjb2x1 bW4pIikKbGFiZWw5LmdyaWQocm93ID0gNCwgY29sdW1uID0gMikKCmZyYW1lOSA9IEZyYW1lKCkK bWFrZXBpZShzdW0sIGZyYW1lOSwgY2Fuc2l6ZSwgcGlleG1pbiwgcGlleG1heCwgcGlleW1pbiwg cGlleW1heCkKZnJhbWU5LmdyaWQocm93ID0gNSwgY29sdW1uID0gMikKCm1haW5sb29wKCk= --Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD-- From dsh8290@rit.edu Wed Jun 13 22:19:45 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 13 Jun 2001 17:19:45 -0400 Subject: [Tutor] PYTHONPATH: where to set on Win9x In-Reply-To: <3B27D0D7.30DB0E5@gmx.de>; from christian.mascher@gmx.de on Wed, Jun 13, 2001 at 10:45:11PM +0200 References: <3B27D0D7.30DB0E5@gmx.de> Message-ID: <20010613171945.A27830@harmony.cs.rit.edu> On Wed, Jun 13, 2001 at 10:45:11PM +0200, Christian Mascher wrote: | So I guess I only have to use PYTHONPATH for having my personal | directories turn up in sys.path, is that right? Meaning I only need | to put set PYTHONPATH=d:\mypython in autoexec.bat to include that | directory. It works, but is it "the right way" or did I miss a | point? You got it. Python knows where to find the standard stuff, you just have to add your stuff. | By the way, is the global autoexec.bat really the best place for putting | this? It is a convenient place, especially if you never change it. | Normally, when I use a console-started compiler (like javac for | instance), I have an extra .bat-script setting the appropriate | environment-variables only when opening the shell (DOS-box) | dedicated to Java or whatever. So it is possible to add environment | variables later. Could/should this be done for the python shell as | well? If you prefer you can use a series of scripts just like with java. The main issue you would run into there is if .py files are associated with python.exe, not your own .bat file. Then they would run python.exe directly and not get your environment changes. I use Linux or cygwin on Windows so I simply put stuff in ~/.bashrc, or I make separate scripts if I need to switch stuff around (such as using a DOS path for $VIM for win32 gvim, and a POSIX path for cygwin's console-vim). I always have one or more console (bash) windows open where I run things from anyways. HTH, -D From israel@lith.com Wed Jun 13 22:48:02 2001 From: israel@lith.com (Israel Evans) Date: Wed, 13 Jun 2001 14:48:02 -0700 Subject: [Tutor] PYTHONPATH: where to set on Win9x Message-ID: I find that I get goofy behavior in Win200 when I set PYTHONPATH to have more than one directory in it. As soon as I add a second dir, Idle stops working. -----Original Message----- From: D-Man [mailto:dsh8290@rit.edu] Sent: Wednesday, June 13, 2001 2:20 PM To: tutor@python.org Subject: Re: [Tutor] PYTHONPATH: where to set on Win9x On Wed, Jun 13, 2001 at 10:45:11PM +0200, Christian Mascher wrote: | So I guess I only have to use PYTHONPATH for having my personal | directories turn up in sys.path, is that right? Meaning I only need | to put set PYTHONPATH=d:\mypython in autoexec.bat to include that | directory. It works, but is it "the right way" or did I miss a | point? You got it. Python knows where to find the standard stuff, you just have to add your stuff. | By the way, is the global autoexec.bat really the best place for putting | this? It is a convenient place, especially if you never change it. | Normally, when I use a console-started compiler (like javac for | instance), I have an extra .bat-script setting the appropriate | environment-variables only when opening the shell (DOS-box) | dedicated to Java or whatever. So it is possible to add environment | variables later. Could/should this be done for the python shell as | well? If you prefer you can use a series of scripts just like with java. The main issue you would run into there is if .py files are associated with python.exe, not your own .bat file. Then they would run python.exe directly and not get your environment changes. I use Linux or cygwin on Windows so I simply put stuff in ~/.bashrc, or I make separate scripts if I need to switch stuff around (such as using a DOS path for $VIM for win32 gvim, and a POSIX path for cygwin's console-vim). I always have one or more console (bash) windows open where I run things from anyways. HTH, -D _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From alan.gauld@freenet.co.uk Wed Jun 13 23:42:10 2001 From: alan.gauld@freenet.co.uk (Alan Gauld) Date: Wed, 13 Jun 2001 22:42:10 +0000 Subject: [Tutor] Embedded Python question Message-ID: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk> This comes from the Czech translators of my tutor. I only use Python for prototyping so have no experience of embedding. However I seem to recall some folks asking here so... >an advice regarding running more than 1 Python embedded interpreter at the >same time? Or could you please give us any impulse where we can find out it? >In the concrete: we need run the Py_RunSimpleString() method >from various C++ threads at the same time. ie, They want to know can they run multiple interpreters (or more accurately call the function) from multiple threads within a single process? Is Python threadsafe at that level? I have no idea, does anyone else? I have suggested they should ask on c.l.p too... Alan g From pobrien@orbtech.com Wed Jun 13 23:22:22 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 13 Jun 2001 17:22:22 -0500 Subject: [Tutor] PYTHONPATH: where to set on Win9x In-Reply-To: <3B27D0D7.30DB0E5@gmx.de> Message-ID: No problem, Christian. I will do my best to answer your questions. And if I mispeak, hopefully someone will correct me. Look for comments below that begin with [POB]. Those would be mine. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Christian Mascher Sent: Wednesday, June 13, 2001 3:45 PM To: tutor@python.org Subject: [Tutor] PYTHONPATH: where to set on Win9x Hello everyone, I've been following the recent postings on implementing a startup-configuration of some sorts, perhaps loading some modules (pydoc) or setting up the path to arbitrary extra module-directories (my private modules). As far as I understood the matter, the module-search-path (shown with 'sys.path') where Python looks for and is able to find modules must (?) be set via the environment variable PYTHONPATH. --- [POB] Yes, with a few exceptions and subtleties. For example, python has some builtin places that it automatically adds to sys.path. Then the IDE that you use (IDLE, PythonWin, VPython and Boa, just to name a few) might make some changes to sys.path. There is also a way for 3rd party packages to specify a directory that always gets added. And since sys.path is just a list, you can always add on to it in your code. (In addition, python's concept of packages can extend its reach into directories that aren't explicitly listed in sys.path.) But the *easiest* way to have one of your own directories *always* visible to python *no matter what* IDE you are using is to add that directory to a SET PYTHONPATH statement in your autoexec.bat file. --- But that doesn't seem to be the whole story on windows, because I can run python and import all standard modules with no explicit PYTHONPATH set in the environment. (During installation the necessary paths must have been hardwired into the registry. --- [POB] Yes, but not necessarily through the registry. --- For the same reason I can start idle by "executing" idle.pyw from the shell (explorer) right?). --- [POB] No. That has to do with the fact that the python installer has associated the .py and .pyw file extensions with python.exe. So if you double click on a file with that extension, Windows knows what to do with that file. This is no different than what happens when you double click on a .doc file and Word pops up. Gnome and KDE do similar things under Linux. In Windows Explorer select the Tools | Folder Options | File Types tab to see the associations: C:\Python21\python.exe "%1" %* (for .py files) and C:\Python21\pythonw.exe "%1" %* (for .pyw files). Notice that the path to python.exe is included, so it doesn't matter whether python is on your PATH for this bit of magic to work. If you want to be able to open a DOS box and go to any directory and type "python" or "python myfile.py" then you need to add your python directory to your PATH either through a batch file or as part of your autoexec.bat, which again is the *easiest* way to go. --- So I guess I only have to use PYTHONPATH for having my personal directories turn up in sys.path, is that right? Meaning I only need to put set PYTHONPATH=d:\mypython in autoexec.bat to include that directory. It works, but is it "the right way" or did I miss a point? --- [POB] Yes, that is all you need. No, I don't think you missed the point. I think this is the right way to go. And if d:\mypython is a python package (see http://www.python.org/doc/current/tut/node8.html#SECTION00840000000000000000 0) you can get to subdirectories of mypython using dot notation (from mypython.mycode.mygame.3d import specialeffects), which is pretty cool, imho. --- By the way, is the global autoexec.bat really the best place for putting this? Normally, when I use a console-started compiler (like javac for instance), I have an extra .bat-script setting the appropriate environment-variables only when opening the shell (DOS-box) dedicated to Java or whatever. So it is possible to add environment variables later. Could/should this be done for the python shell as well? One could of course append to sys.path in a standard startupscript, but then I have to set PYTHONSTARUP first, yes? --- [POB] Again, putting it in autoexec.bat is just easy and global. If you keep it simple, you only need to do it once. Otherwise you need to make sure you set up every desktop shortcut/menu choice/toolbar shortcut, etc. to go through your batch files for every tool you use (and I actively use IDLE, Boa, PythonWin and VPython). I would not want to have to hassle with that myself. I have a *ton* of software loaded on this machine and my autoexec.bat file consists of only these three lines: SET PATH=C:\Python21 SET PYTHONPATH=C:\My Documents\pobrien\Code SET PYTHONSTARTUP=C:\My Documents\pobrien\.pythonrc.py --- Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo just sorted out, but I'm really still confused about the issue. --- [POB] Don't feel bad. I still think these environmental issues are one of the weakest areas. I don't know if it's a lack of documentation or what. But it seems like everyone (myself included) gets completely baffled when they come to the environment and startup issues. I hope this helped. --- Thanks in advance, Christian _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From arcege@speakeasy.net Wed Jun 13 23:43:09 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 13 Jun 2001 18:43:09 -0400 (EDT) Subject: [Tutor] Embedded Python question In-Reply-To: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk> from "Alan Gauld" at Jun 13, 2001 10:42:10 PM Message-ID: <200106132243.f5DMhA501379@dsl092-074-184.bos1.dsl.speakeasy.net> Alan Gauld wrote > > This comes from the Czech translators of my tutor. > I only use Python for prototyping so have no experience > of embedding. However I seem to recall some folks asking > here so... > > >an advice regarding running more than 1 Python embedded interpreter at the > >same time? Or could you please give us any impulse where we can find out it? > >In the concrete: we need run the Py_RunSimpleString() method > >from various C++ threads at the same time. > > ie, They want to know can they run multiple interpreters (or > more accurately call the function) from multiple threads > within a single process? Is Python threadsafe at that level? > I have no idea, does anyone else? If they don't care about different interpreters (with different namespaces and not sharing variables and modules), then they can just wrap the code some of the standard macros around the functions: Py_BEGIN_BLOCK_THREADS PyRun_SimpleString(...); Py_BEGIN_UNBLOCK_THREADS Otherwise you have to start getting into the lower level thread state functions. PyThreadState *tstate_1, *tstate_2; Py_Initialize(); PyEval_InitThreads(); tstate_1 = Py_NewInterpreter(); tstate_2 = Py_NewInterpreter(); /* create threads */ ... /* in thread 1 */ PyEval_AcquireThread(tstate_1); PyRun_SimpleString(...); PyEval_ReleaseThread(tstate_1); ... /* in thread 2 */ PyEval_AcquireThread(tstate_2); PyRun_SimpleString(...); PyEval_ReleaseThread(tstate_2); This is untested, and I might have some of the functions slightly incorrect, but the logic should be sound. It could be that the interpreters are created inside the peer threads instead of the main thread (it looks safe enough). Tim Peters could probably give a more definitive answer tho. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From pobrien@orbtech.com Thu Jun 14 00:02:32 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Wed, 13 Jun 2001 18:02:32 -0500 Subject: [Tutor] PYTHONPATH: where to set on Win9x In-Reply-To: Message-ID: Just to clarify/correct one statement I made - d:\mypython doesn't actually need to be a package itself (though it could be). It could simply contain other directories that were themselves packages. So in the example I gave mycode would have to be a package (as would mygame and 3d) but mypython would not have to be. If it wasn't the import statement would then be: from mycode.mygame.3d import specialeffects What I was trying to show is the amount of flexibility that packages can give you. In this scenario, you only need one directory on your PYTHONPATH that contains all of your own personal code. But that personal code can exist in as many subdirectories as you require to stay organized. Just make each subdirectory a package (by adding a __init__.py file to the subdirectory) and it becomes visible to python, even though it isn't in sys.path. That way each is like an independent project, yet visible to python without requiring you to mess with PYTHONPATH or sys.path every time you add a new project. Does that make sense? (If not I give up. Just kidding. ) --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Patrick K. O'Brien Sent: Wednesday, June 13, 2001 5:22 PM To: tutor@python.org Subject: RE: [Tutor] PYTHONPATH: where to set on Win9x So I guess I only have to use PYTHONPATH for having my personal directories turn up in sys.path, is that right? Meaning I only need to put set PYTHONPATH=d:\mypython in autoexec.bat to include that directory. It works, but is it "the right way" or did I miss a point? --- [POB] Yes, that is all you need. No, I don't think you missed the point. I think this is the right way to go. And if d:\mypython is a python package (see http://www.python.org/doc/current/tut/node8.html#SECTION00840000000000000000 0) you can get to subdirectories of mypython using dot notation (from mypython.mycode.mygame.3d import specialeffects), which is pretty cool, imho. --- From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 00:00:19 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 13 Jun 2001 16:00:19 -0700 (PDT) Subject: [Tutor] PYTHONPATH: where to set on Win9x In-Reply-To: <3B27D0D7.30DB0E5@gmx.de> Message-ID: On Wed, 13 Jun 2001, Christian Mascher wrote: > So I guess I only have to use PYTHONPATH for having my personal > directories turn up in sys.path, is that right? Meaning I only need to > put set PYTHONPATH=d:\mypython in autoexec.bat to include that > directory. It works, but is it "the right way" or did I miss a point? Yes. PYTHONPATH's for personal configuration --- if we have a bunch of modules that we've written, we can plunk them anywhere in the PYTHONPATH, and we'll be able to reuse them. That's what makes Python really neat: even the simplest programs that we write are already reusable without too much work. > By the way, is the global autoexec.bat really the best place for > putting this? Normally, when I use a console-started compiler (like > javac for It actually depends on what Windows edition we're using. Up to Win98, putting it in autoexec.bat was the one of the better choices, since there's only one "user". On NT and Win2k, each user has a set of personalized variables, modifiable through the Control Panel. I forget the control-panel applet name, but it has the word "Environment Variables" in it somewhere. > Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo > just sorted out, but I'm really still confused about the issue. No problem; just as long as we don't contradict ourselves, I think we'll be fine... *grin* From dsh8290@rit.edu Thu Jun 14 00:04:31 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 13 Jun 2001 19:04:31 -0400 Subject: [Tutor] Embedded Python question In-Reply-To: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk>; from alan.gauld@freenet.co.uk on Wed, Jun 13, 2001 at 10:42:10PM +0000 References: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk> Message-ID: <20010613190431.A9847@idaho.cs.rit.edu> On Wed, Jun 13, 2001 at 10:42:10PM +0000, Alan Gauld wrote: | This comes from the Czech translators of my tutor. | I only use Python for prototyping so have no experience | of embedding. However I seem to recall some folks asking | here so... | | >an advice regarding running more than 1 Python embedded interpreter at the | >same time? Or could you please give us any impulse where we can find out it? | >In the concrete: we need run the Py_RunSimpleString() method | >from various C++ threads at the same time. | | ie, They want to know can they run multiple interpreters (or | more accurately call the function) from multiple threads | within a single process? Is Python threadsafe at that level? | I have no idea, does anyone else? I haven't done any embedding, but from what I understand the issue is mainly that the Python stack is intertwined with the C stack. Stackless Python would probably be safer for this because it stores the Python stack separately on the C heap, so as long as it can switch between different Python stacks, it can have different interpreters (probably even allowing for shared globals, etc). -D From dsh8290@rit.edu Thu Jun 14 00:06:05 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 13 Jun 2001 19:06:05 -0400 Subject: [Tutor] PYTHONPATH: where to set on Win9x In-Reply-To: ; from israel@lith.com on Wed, Jun 13, 2001 at 02:48:02PM -0700 References: Message-ID: <20010613190605.B9847@idaho.cs.rit.edu> On Wed, Jun 13, 2001 at 02:48:02PM -0700, Israel Evans wrote: | I find that I get goofy behavior in Win200 when I set PYTHONPATH to have | more than one directory in it. As soon as I add a second dir, Idle stops | working. How are you adding a second dir? Windows uses ';' to separate paths in a path list (very bad for interracting in "real" (ie bash) shells because ';' terminates a command). -D From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 00:09:49 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 13 Jun 2001 16:09:49 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! In-Reply-To: <200106131502.f5DF2dg12285@pop.nsacom.net> Message-ID: On Wed, 13 Jun 2001 kromag@nsacom.net wrote: > > Let's look at the rest of the program: > > > > > import string > > > import thread > > > > > > engine=win32com.client.Dispatch("DAO.DBEngine.35") > > > db=engine.OpenDatabase("windowsdesktopterror.mdb") > > > > Ok, I'm not imagining things after all. *grin* There are backslashes on > > this line: can you double check? > > But, but, but..... Really! I am looking at the code I pasted in! It has > double backslashes! What manner of madness? Surely your mail agent doesn't > parse them into links? Anyway, I tried it with the r"pathtofile" method > and got the same error: Strange! Now I'm really confused. I'm using Pine as my email program, which I don't think does any email preprocessing. My apologies for my earlier message; I didn't realize the messages were being mangled. Sorry about the confusion there. What kind of email program are you using? > >pythonw -u dbwrong.py > Unhandled exception in thread: > Traceback (most recent call last): > File "dbwrong.py", line 15, in write > db.Execute("insert into data values(%f, '%s')" % inputtage) > AttributeError: 'None' object has no attribute 'Execute' > >Exit code: 0 The assumption I'm working on is that 'db' itself is None. If you could add the line: ### if db == none: print "We didn't get the database connection yet." ### right before the Execute, that will help test this guess. I'm focusing on the engine.OpenDatabase() call earlier, because that's where 'db' is being initialized. > Ah well. I am going to not think about it for a week. That has > traditionally been the length of time it takes for the answer to > coalesce out of the aether! :-) Don't worry about it. My head is starting to spin too... *grin* Again, sorry about the bad advice earlier. I have to learn to be more careful when I'm reading messages. You may want to talk with the people on the db-sig a bit more; it sounds like they have good experience with the Jet database stuff. Good luck to you! From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 00:13:19 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 13 Jun 2001 16:13:19 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! In-Reply-To: Message-ID: > if db == none: > print "We didn't get the database connection yet." Whoops! I meant: if db == None: print "We didn't get the database connection yet." From gncuster@firehead.org Thu Jun 14 00:28:04 2001 From: gncuster@firehead.org (Nate Custer) Date: 13 Jun 2001 18:28:04 -0500 Subject: [Tutor] Dict question Message-ID: <992474884.22310.0.camel@it.web> --=-AGVnSkuT5LiNtNpkWBA5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all, I am calling a dict (format should be {string: [list]} ). It fails as: File "guardian_sum.py", line 45, in scan l.append(error_ip) AttributeError: 'string' object has no attribute 'append' Why does the error_dict.get() return a string? Thanks in advance, Nate Custer ====================================Begin Code ========================== error_dict = {} def scan(): guardian = open("/var/log/guardian/guardian.log", 'r') ipchains = open("/home/nsc/ipchains.log", 'w') odd = open("/home/nsc/odd.log", 'w') nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ] days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] blocked_host = [] while 1: # read the line line = guardian.readline() if not line: break if line[:3] in days: word = string.split (line) for w in word: if 'IDS' == w[:3]: error = w if w[0] in nums: error_ip = w if error_dict.has_key(error): l = error_dict.get(error) l.append(error_ip) append = {error: l} error_dict.update (append) else: x = [`error_ip`] append = {error: x} error_dict.update (append) --=-AGVnSkuT5LiNtNpkWBA5 Content-Type: text/html; charset=utf-8 Hi all,

I am calling a dict (format should be {string: [list]} ). It fails as:

 File "guardian_sum.py", line 45, in scan
   l.append(error_ip)
AttributeError: 'string' object has no attribute 'append'

Why does the error_dict.get() return a string?

Thanks in advance,

Nate Custer

====================================Begin Code ==========================
error_dict = {}

def scan():
   guardian = open("/var/log/guardian/guardian.log", 'r')
   ipchains = open("/home/nsc/ipchains.log", 'w')
   odd = open("/home/nsc/odd.log", 'w')

   nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]
   days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
   blocked_host = []

   while 1:
       # read the line
       line = guardian.readline()
       if not line: break
       
       if line[:3] in days:

           word = string.split (line)
           for w in word:
               if 'IDS' == w[:3]:
                   error = w
               if w[0] in nums:
                   error_ip = w


           if error_dict.has_key(error):
               l = error_dict.get(error)
               l.append(error_ip)
               append = {error: l}
               error_dict.update (append)
           else:
               x = [`error_ip`]
               append = {error: x}
               error_dict.update (append) --=-AGVnSkuT5LiNtNpkWBA5-- From kauphlyn@speakeasy.org Thu Jun 14 00:59:58 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Wed, 13 Jun 2001 16:59:58 -0700 (PDT) Subject: [Tutor] Dict question In-Reply-To: <992474884.22310.0.camel@it.web> Message-ID: > if error_dict.has_key(error): > l = error_dict.get(error) > l.append(error_ip) > append = {error: l} > error_dict.update (append) > else: > x = [`error_ip`] > append = {error: x} > error_dict.update (append) > if error_dict.has_key(error): l = [] l.append(error_dict.get(error)) l.append(error_ip) etc. I've never used the get() before but it appears to return the value associated with the key, which in this case is a string. You were then assigning that string to l. In this case we declare l as a list first then append values to it. That should work for you. (I didnt test it!) Hope this helps! Daniel From r.b.rigilink@chello.nl Thu Jun 14 05:05:50 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Thu, 14 Jun 2001 06:05:50 +0200 Subject: [Tutor] Building custom widget (was: (no subject)) References: <01061315265100.26218@ouhep1> <002801c0f44a$da32e660$de00a8c0@planhouse5> <01061316152200.27433@ouhep1> Message-ID: <3B28381E.1C2E7A31@chello.nl> Isaac Hall wrote: Hi Isaac, I took a look at your program, and I think this will be easy for you to do, provided you're familiar with Python's OO programming idioms. If it's not obvious what I'm trying to show, feel free to ask for additional clarification. If you find in your code that you do something like: def draw_widget(aframe, *args): f = Frame(parent) draw_widget(f, *args) f.pack() Then you can build your own widget, by inheriting from Frame, using your draw_widget function almost verbatim (changing aframe to self). class MyWidget(Frame): def __init__(self, parent, *args): Frame.__init__(self, parent) self.draw_widget(*args) def draw_widget(self, *args): f = MyWidget(parent, *args) f.pack() # or f.grid(...) Hope this helps, Roeland > > On Wed, 13 Jun 2001, Rob Andrews wrote: > > ----- Original Message ----- > > From: "Isaac Hall" > > To: > > Sent: Wednesday, June 13, 2001 3:24 PM > > Subject: [Tutor] (no subject) > > > > > > > hello all (again) > > > I would like to pose a (hopefully) quick and easy question that is > > confounding > > > me. in a program I am trying to write, it has become apparent to me that > > I > > > need to create my own widget to place in a Tk window to accomplish what I > > need. > > > How can I do this??? if I am being to vague, let me know and I will > > clarify. > > > > > > thanks > > > Ike > > > > > If you can provide a little more detail about your challenge, it would help. > > For instance, what is it that you are trying to do. There are some really > > interesting widgets available out there already. Can you show any code that > > is tripping you in particular? > > > > Rob > > > > Useless Python > > It's not just for breakfast anymore! > > http://www.lowerstandard.com/python/index.html > > yes I can, specifically Im trying to put several pie charts in a window, that > can be sized and moved about as the user wants. (at least by changing a value > or two) as of now, I can do this by defining a function that makes the piechart > on a canvas which is put in a frame, which is then put in a grid by the grid > geometry manager. however, the powers that be tell me it would be fantastic if > I could do this by skipping the nasty canvas to frame thing altogether, and > create a piechart widget (or class or something like that), which I could > directly throw into the geometry manager, and hopefully create more ease in > allowing the user to specify location, size, etc. this is where Im stuck. > Ive attached a sample of what it is Im doing, which works just fine, but they > just want no canvases...... > > ------------------------------------------------------------------------ > Name: tester.py > tester.py Type: text/x-java > Encoding: base64 > Description: test pies -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From r.b.rigilink@chello.nl Thu Jun 14 05:19:31 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Thu, 14 Jun 2001 06:19:31 +0200 Subject: [Tutor] Dict question References: <992474884.22310.0.camel@it.web> Message-ID: <3B283B53.7B2EDA1@chello.nl> Hi Nate, As far as I can tell your code is not wrong (Is this everything there is), so given this I don't understand the error. However, it is somewhat unconventional, which may hide the error from me. The idiom for what you're trying to do with updating your dict is: l = error_dict.get(error, []) # if error in dict get list, else return empty list l.append(error_ip) error_dict[error] = l # put list (back) in dict Hope this helps, Roeland > Nate Custer wrote: > > Hi all, > > I am calling a dict (format should be {string: [list]} ). It fails as: > > File "guardian_sum.py", line 45, in scan > l.append(error_ip) > AttributeError: 'string' object has no attribute 'append' > > Why does the error_dict.get() return a string? > > Thanks in advance, > > Nate Custer > > ====================================Begin Code > ========================== > error_dict = {} > > def scan(): > guardian = open("/var/log/guardian/guardian.log", 'r') > ipchains = open("/home/nsc/ipchains.log", 'w') > odd = open("/home/nsc/odd.log", 'w') > > nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ] > days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] > blocked_host = [] > > while 1: > # read the line > line = guardian.readline() > if not line: break > > if line[:3] in days: > > word = string.split (line) > for w in word: > if 'IDS' == w[:3]: > error = w > if w[0] in nums: > error_ip = w > This is unconventional: > if error_dict.has_key(error): > l = error_dict.get(error) > l.append(error_ip) > append = {error: l} > error_dict.update (append) > else: > x = [`error_ip`] > append = {error: x} > error_dict.update (append) -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 07:52:35 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 13 Jun 2001 23:52:35 -0700 (PDT) Subject: [Tutor] Dict question In-Reply-To: <992474884.22310.0.camel@it.web> Message-ID: Dear Nate, Hello! I couldn't see problems with your code either. As a debugging tip: try printing out your dictionary right before the append(): that might reveal a problem with the error_dict. Hypothesis: Perhaps another function that gets called before scan() disfigures error_dict in some hideous mangling: that could cause the sort of error that you're getting. I'm always wary when I see global variables, so please indulge my excessive despair... *grin* Some comments on your code: > if error_dict.has_key(error): > l = error_dict.get(error) > l.append(error_ip) Up to this part, things are ok. In fact, you can stop right here --- the next two lines: > append = {error: l} > error_dict.update (append) aren't necessary: you can remove them. The reason is because the list associated with our 'error' key has already been changed by the 'l.append(error_ip)' line above. When we're using l = error_dict.get(error) we're getting back the literal list that's associated with the key. That is, we're not getting some cheap imitation: we're getting the one true list --- any changes that we make to this list 'l' appears to get reflected back in the dictionary, because it IS the list from the dictionary. Here's an example that shows this in action: ### >>> book_characters = {} >>> book_characters['lord of the rings'] = ['frodo'] >>> book_characters['lord of the rings'].append('sam') >>> book_characters['lord of the rings'] ['frodo', 'sam'] >>> characters = book_characters['lord of the rings'] >>> characters.append('gandalf') >>> book_characters['lord of the rings'] ['frodo', 'sam', 'gandalf'] ### Another thing that you might want to look at is: is 'error_ip' itself a string? If not, then you'll want to make it into a string with the backquotes: l.append(`error_ip`) before you insert it into the list, to maintain the desire for all those list elements to be strings. Your else clause, later in the code, treats 'error_ip' with backquotes, so you might want to keep the symmetry. One comment on the else clause: > else: > x = [`error_ip`] > append = {error: x} > error_dict.update (append) We're using this else clause to add a new key-value binding to our error_dict. In this case, it's more direct to add it: else: error_dict[error] = [`error_ip`] without having to worry about calling update(). dict.update() is meant to let people merge two large dictionaries together, but it's overkill in this case. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 08:00:04 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 14 Jun 2001 00:00:04 -0700 (PDT) Subject: [Tutor] Building custom widget (was: (no subject)) In-Reply-To: <3B28381E.1C2E7A31@chello.nl> Message-ID: > yes I can, specifically Im trying to put several pie charts in a > window, that can be sized and moved about as the user wants. (at least > by changing a value or two) as of now, I can do this by defining a > function that makes the piechart on a canvas which is put in a frame, > which is then put in a grid by the grid geometry manager. however, the > powers that be tell me it would be fantastic if I could do this by > skipping the nasty canvas to frame thing altogether, and create a > piechart widget (or class or something like that), which I could By the way, there's a pie chart generator called 'Graphite': perhaps you can make use of it to generate your pie charts without even fiddling with Tkinter widgets: http://Graphite.sourceforge.net Another useful graphics module is called PIDDLE: http://piddle.sourceforge.net which Graphite appears to work with. Both work nicely with Tkinter, so play with it and see if it fits your needs. From ppathiyi@cisco.com Thu Jun 14 12:27:31 2001 From: ppathiyi@cisco.com (Praveen Pathiyil) Date: Thu, 14 Jun 2001 16:57:31 +0530 Subject: [Tutor] Installing Python2.1.. Problem with _tkinter Message-ID: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc> This is a multi-part message in MIME format. ------=_NextPart_000_07B8_01C0F4F3.19EF3030 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I am facing problems in installing python 2.1 in a solaris = machine. The errors are coming when i am trying to include the Tkinter = module -------------------------------XXXXXXXXXXXXXXX------------------------- libpython2.1.a(_tkinter.o): In function `Tkinter_Error': /proj/vsc/python/Python-2.1/./Modules/_tkinter.c:233: undefined = reference to `Tc l_GetStringResult' libpython2.1.a(_tkinter.o): In function `Merge': /proj/vsc/python/Python-2.1/./Modules/_tkinter.c:350: undefined = reference to `Tc l_Merge' libpython2.1.a(_tkinter.o): In function `Split': /proj/vsc/python/Python-2.1/./Modules/_tkinter.c:382: undefined = reference to `Tc l_SplitList' /proj/vsc/python/Python-2.1/./Modules/_tkinter.c:407: undefined = reference to `Tc l_Free' libpython2.1.a(_tkinter.o): In function `Tkapp_New': /proj/vsc/python/Python-2.1/./Modules/_tkinter.c:454: undefined = reference to `Tc l_CreateInterp' = ------------------------------XXXXXXXXXXXXXXXXXX-------------------------= --------- I have included the paths for Tcl and Tk headers and libraries. I have = also made the whole comand into a single line as suggested in the=20 Setup file.=20 _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT = -L/auto/sw/packages/cygnus/progre ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include = -I/usr/X11R6/i nclude -I/usr/openwin/include = -L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11 Still i am getting the same errors ....... Please help me out .. Thanks in advance, Praveen. ------=_NextPart_000_07B8_01C0F4F3.19EF3030 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all,
 
        I = am facing=20 problems in installing python 2.1 in a solaris machine. The errors are = coming=20 when i am trying to include the Tkinter module
 
-------------------------------XXXXXXXXXXXXXXX------------------= -------
 
libpython2.1.a(_tkinter.o): In function = `Tkinter_Error':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:233:= =20 undefined reference to = `Tc
l_GetStringResult'
libpython2.1.a(_tkinter.o):=20 In function = `Merge':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:350:=20 undefined reference to `Tc
l_Merge'
libpython2.1.a(_tkinter.o): In = function = `Split':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:382:=20 undefined reference to=20 `Tc
l_SplitList'
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:4= 07:=20 undefined reference to `Tc
l_Free'
libpython2.1.a(_tkinter.o): In = function=20 `Tkapp_New':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:454: = undefined=20 reference to `Tc
l_CreateInterp'
=20 ------------------------------XXXXXXXXXXXXXXXXXX-------------------------= ---------
 
I have included the paths for Tcl and = Tk headers=20 and libraries. I have also made the whole comand into a single line as = suggested=20 in the
Setup file.
 
_tkinter _tkinter.c tkappinit.c = -DWITH_APPINIT=20 -L/auto/sw/packages/cygnus/progre
ssive-98r1-v0/H-sparc-sun-solaris2.5= /lib=20 -I/auto/usrlocal/include -I/usr/X11R6/i
nclude -I/usr/openwin/include = -L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s
parc-sun-solaris2.5= /lib=20 -L/usr/X11R6/lib -L/usr/openwin/lib -lX11
Still i am getting the same errors=20 .......
 
Please help me out ..
 
Thanks in advance,
Praveen.
------=_NextPart_000_07B8_01C0F4F3.19EF3030-- From scarblac@pino.selwerd.nl Thu Jun 14 12:37:40 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 14 Jun 2001 13:37:40 +0200 Subject: [Tutor] Installing Python2.1.. Problem with _tkinter In-Reply-To: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc>; from ppathiyi@cisco.com on Thu, Jun 14, 2001 at 04:57:31PM +0530 References: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc> Message-ID: <20010614133740.A3159@pino.selwerd.nl> On 0, Praveen Pathiyil wrote: > I have included the paths for Tcl and Tk headers and libraries. I have also made the whole comand into a single line as suggested in the > Setup file. > > _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -L/auto/sw/packages/cygnus/progre > ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include -I/usr/X11R6/i > nclude -I/usr/openwin/include -L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s > parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11 I don't see a -L and -I option for the Tcl/Tk directories here. Try adding them, maybe that helps. -- Remco Gerlich From aschmidt@nv.cc.va.us Thu Jun 14 12:52:28 2001 From: aschmidt@nv.cc.va.us (Schmidt, Allen J.) Date: Thu, 14 Jun 2001 07:52:28 -0400 Subject: [Tutor] Get it, Parse it, Dump it.... Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0B9@novamail.nvcc.vccs.edu> Hello All... I've been lurking for a few weeks and now need the services of this list. I have a URL which connects to someone else's database system and returns what I have been told is "compact XML." Having never heard of it before I was curious. Submitting the URL in a browser I get back a ton of data that is lumped together on the screen. A view source shows something else. The first 2 lines are tag-like and the data starts on the third line. That line contains this: NAME ADDRESS PHONE The above data is substituted to make this easier and the line really has about 80 fields. Each field is separated by a TAB character. Then all the following lines look like this: (several hundred lines) Fred 1123 Main Street 555-1212 This goes on until the end where there is another ending-tag-like tag on the very last line. Here is what I need to be able to do AUTOMATICALLY: 1)Submit the URL (I can get the data back by using urllib.urlopen(url) ) 2)Parse the data to remove the first 2 lines and the last line. 3)Parse each line to remove the start and end tags. 4)Make a connection to an ODBC data source on the same PC. 5)Delete all the data in a table. 6)'Pour' all the new data into the appropriate fields in the table 7)Send me an email letting me know the status of the job - number or records, etc. That's it! I have been able to do some of the things at the winPython prompt but not sure how to proceed with the details of make this into a stand-alone py file that handles all these things. My thought would be to CHRON this to have it run at night to update my data. So...thoughts, comments, directions... Don't want someone to DO it for me but I think I need some basic help in putting the pieces together. If its too much to ask of this list, I would like to know that too. Thanks! Allen From ppathiyi@cisco.com Thu Jun 14 13:38:13 2001 From: ppathiyi@cisco.com (Praveen Pathiyil) Date: Thu, 14 Jun 2001 18:08:13 +0530 Subject: [Tutor] Installing Python2.1.. Problem with _tkinter References: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc> <20010614133740.A3159@pino.selwerd.nl> Message-ID: <07ed01c0f4ce$e087a440$37ef87c0@ppathiyipc> ----- Original Message ----- From: "Remco Gerlich" To: Sent: Thursday, June 14, 2001 5:07 PM Subject: Re: [Tutor] Installing Python2.1.. Problem with _tkinter > On 0, Praveen Pathiyil wrote: > > I have included the paths for Tcl and Tk headers and libraries. I have also made the whole comand into a single line as suggested in the > > Setup file. > > > > _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -L/auto/sw/packages/cygnus/progre > > ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include -I/usr/X11 R6/i > > nclude -I/usr/openwin/include -L/auto/sw/packages/cygnus/progressive-98r1-v0 /H-s > > parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11 > > I don't see a -L and -I option for the Tcl/Tk directories here. > > Try adding them, maybe that helps. The Tcl and Tk libraries are in the directory auto/sw/packages/cygnus/progressive-98r1-v0/H-sparc-sun-solaris2.5/lib and the header files are in the directory auto/usrlocal/include both of which are included ..... Any other possible reasons ? Thx, Praveen. From pobrien@orbtech.com Thu Jun 14 15:01:07 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Thu, 14 Jun 2001 09:01:07 -0500 Subject: [Tutor] Get it, Parse it, Dump it.... In-Reply-To: <5CDFEBB60E7FD311B9E30000F6D6090688C0B9@novamail.nvcc.vccs.edu> Message-ID: I can't speak for anyone else, but it would help me help you if you could expand on what you have that *is* working and what *specifically* you still need on the other things. Otherwise it's a pretty big list. I know some of the answers, but I don't know if you want advice on where to start or whether you want to see sample code or whether you have some code and it isn't doing exactly what you want. So now that we know the scope of your project (which sounds pretty cool, btw) maybe you could break out some specific requests so that we can help you with smaller chunks until you have everything that you need. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Schmidt, Allen J. Sent: Thursday, June 14, 2001 6:52 AM To: tutor@python.org Subject: [Tutor] Get it, Parse it, Dump it.... Hello All... I've been lurking for a few weeks and now need the services of this list. I have a URL which connects to someone else's database system and returns what I have been told is "compact XML." Having never heard of it before I was curious. Submitting the URL in a browser I get back a ton of data that is lumped together on the screen. A view source shows something else. The first 2 lines are tag-like and the data starts on the third line. That line contains this: NAME ADDRESS PHONE The above data is substituted to make this easier and the line really has about 80 fields. Each field is separated by a TAB character. Then all the following lines look like this: (several hundred lines) Fred 1123 Main Street 555-1212 This goes on until the end where there is another ending-tag-like tag on the very last line. Here is what I need to be able to do AUTOMATICALLY: 1)Submit the URL (I can get the data back by using urllib.urlopen(url) ) 2)Parse the data to remove the first 2 lines and the last line. 3)Parse each line to remove the start and end tags. 4)Make a connection to an ODBC data source on the same PC. 5)Delete all the data in a table. 6)'Pour' all the new data into the appropriate fields in the table 7)Send me an email letting me know the status of the job - number or records, etc. That's it! I have been able to do some of the things at the winPython prompt but not sure how to proceed with the details of make this into a stand-alone py file that handles all these things. My thought would be to CHRON this to have it run at night to update my data. So...thoughts, comments, directions... Don't want someone to DO it for me but I think I need some basic help in putting the pieces together. If its too much to ask of this list, I would like to know that too. Thanks! Allen _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From rob@jam.rr.com Thu Jun 14 15:57:38 2001 From: rob@jam.rr.com (Rob Andrews) Date: Thu, 14 Jun 2001 09:57:38 -0500 Subject: [Tutor] a couple of ideas I've been bouncing around Message-ID: In my ongoing quest for novel (twisted?) ways to add even more color to the Python universe, I've come up with a few more ideas. I picked up Trivial Pursuit Genus 5 the other day and thought it would be interesting to produce a Python module for it, essentially a collection of questions and answers about Python, broken down by general category (e.g., "Python Mythology", "Data Structures", "Python History", etc.) using a color scheme compatible with the one Trivial Pursuit uses. This could be printed up on some nice card stock and actually used with the boxed game set. The second idea is an actual test. Brainbench (http://www.brainbench.com) offers a $19.95 certification in Python 1.5. With all the keen, experienced minds and nearly inexhaustible number of questions archived on this list, we should be able to come up with a nice test that generates a brief, meaningful report on how one performed on it. """You were strong enough to tutor another person in the areas of "strings" and "exception handling". You seemed competent in "flow control" and "sockets". You should study more on "OOP" and "embedding". You answered 87% correctly, soundly passing Python Tutor Certification.""" I think anything we do along these general lines would help provide another great learning tool and a healthy bit of fun all around. Rob "Perl is worse than Python because people wanted it worse." Larry Wall (Creator of Perl), 14 Oct 1998 Useless Python: http://www.lowerstandard.com/python/ From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 16:01:23 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 14 Jun 2001 08:01:23 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! (fwd) Message-ID: Hiya kormag, Let me forward this to the other people on tutor. I've never used TWIG, so I'm inclined to suspect it. *grin* ---------- Forwarded message ---------- Date: Thu, 14 Jun 2001 08:27:48 -0700 (PDT) From: kromag@nsacom.net To: Daniel Yoo , Daniel Yoo , kromag@nsacom.net Cc: tutor@python.org Subject: Re: [Tutor] Threads.... Unhandle my Exception you Feind! Daniel Yoo said: > > But, but, but..... Really! I am looking at the code I pasted in! It has > > double backslashes! What manner of madness? Surely your mail agent doesn't > > parse them into links? Anyway, I tried it with the r"pathtofile" method > > and got the same error: > > > Strange! Now I'm really confused. I'm using Pine as my email program, > which I don't think does any email preprocessing. My apologies for my > earlier message; I didn't realize the messages were being mangled. Sorry > about the confusion there. What kind of email program are you using? > I post to this list using TWIG (a web interface that in this instance uses perl, PHP and apache w/ssl on OpenBSD. Nice interface and fairly secure for webmail.) > > > >pythonw -u dbwrong.py > > Unhandled exception in thread: > > Traceback (most recent call last): > > File "dbwrong.py", line 15, in write > > db.Execute("insert into data values(%f, '%s')" % inputtage) > > AttributeError: 'None' object has no attribute 'Execute' > > >Exit code: 0 > > The assumption I'm working on is that 'db' itself is None. If you could > add the line: > > ### > if db == none: > print "We didn't get the database connection yet." Oho! > ### > > right before the Execute, that will help test this guess. I'm focusing on > the engine.OpenDatabase() call earlier, because that's where 'db' is being > initialized. > Aha! I smell a rat! Here again is the script with your mods and the output: ----------begin dbwrong.py-------------- import win32com.client import random import time import string import thread engine=win32com.client.Dispatch("DAO.DBEngine.35") db=engine.OpenDatabase(r"windowsdesktopterror.mdb") ## Function write() writes a list to the database def write(inputtage): if db==None: print 'el vomito' db.Execute("insert into data values(%f, '%s')" % inputtage) return 'ok' if __name__=='__main__': tik_tok=time.time() surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) the_madness=(tik_tok, surprize) thread.start_new_thread(write,(the_madness,)) --------------end dbwrong.py---------------- and the errors: ---------begin error------------------------ >pythonw -u dbwrong.py el vomito ## There you are you rascal! Unhandled exception in thread: Traceback (most recent call last): File "dbwrong.py", line 15, in write db.Execute("insert into data values(%f, '%s')" % inputtage) AttributeError: 'None' object has no attribute 'Execute' >Exit code: 0 ---------end error------------------------- > Don't worry about it. My head is starting to spin too... *grin* Again, > sorry about the bad advice earlier. I have to learn to be more careful > when I'm reading messages. My orbital migrane platforms are trained upon you now. Soon you will learn to trifle with..... Man, I really need a good mad scientist name. > > You may want to talk with the people on the db-sig a bit more; it sounds > like they have good experience with the Jet database stuff. Good luck to > you! > I shall! It just seems durn weird that adding a single thread causes the database name to be spat out. Weird, man. I will post any solution. d > From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 16:16:38 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 14 Jun 2001 08:16:38 -0700 (PDT) Subject: [Tutor] Taking Mark Lutz's training course In-Reply-To: <200106141532.f5EFWag19056@pop.nsacom.net> Message-ID: On Thu, 14 Jun 2001 kromag@nsacom.net wrote: > Daniel Yoo said: > > > > > Whoops! I meant: > > > > if db == None: > > Caught it! > > And now for something completely different: > > Have you taken, or talked to anyone who has taken Mark Lutz' Python > classes? It sounds like a good three days, but the money gods have > frowned upon me this year. I _really_ get a lot of mileage out of > "Learning Python", so I am inclined toward spending my dough with him. No, I haven't taken one of his classes. Has anyone here taken one? What are they like? > I have yet to find a college in the midwest that even teaches Python. > *sigh* I actually tried to do a small "Introduction to Python" session in Berkeley once. What a disaster! The problem was that the language was so obvious, so simple, that I didn't need to say anything... *grin* Truthfully, I'd need to improve my speaking skills before tackling something like that. From aschmidt@nv.cc.va.us Thu Jun 14 16:17:03 2001 From: aschmidt@nv.cc.va.us (Schmidt, Allen J.) Date: Thu, 14 Jun 2001 11:17:03 -0400 Subject: [Tutor] Get it, Parse it, Dump it.... Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0C2@novamail.nvcc.vccs.edu> Great! Thanks for responding. >From the winPython interpreter, one line at a time, I do this: >>> import urllib >>> x=urllib.urlopen("http://site.that.has.the.data/search?etc=stuff") ## This takes 2 minutes to come back >>> print x.readlines() And this shows everything on one LONG line coded as I describe below with the TAB character showing between each field as '\011' I have been able to use string.split to break the line into a list on the TAB character. Not sure how to go about building this into something that can run on its own instead of the command prompt. Also need to know how to connect to and talk to my ODBC defined database (Access2000) and then take the fields, one line at a time, and insert them into the DB table. I am using Zope so if there is a way to build this into a script or external method and call it from Zope that would be great too. Using Zope, I have put off learning Python long enough. Now I really need it! Thanks Allen -----Original Message----- From: Patrick K. O'Brien [mailto:pobrien@orbtech.com] Sent: Thursday, June 14, 2001 10:01 AM To: Python Tutor Subject: RE: [Tutor] Get it, Parse it, Dump it.... I can't speak for anyone else, but it would help me help you if you could expand on what you have that *is* working and what *specifically* you still need on the other things. Otherwise it's a pretty big list. I know some of the answers, but I don't know if you want advice on where to start or whether you want to see sample code or whether you have some code and it isn't doing exactly what you want. So now that we know the scope of your project (which sounds pretty cool, btw) maybe you could break out some specific requests so that we can help you with smaller chunks until you have everything that you need. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Schmidt, Allen J. Sent: Thursday, June 14, 2001 6:52 AM To: tutor@python.org Subject: [Tutor] Get it, Parse it, Dump it.... Hello All... I've been lurking for a few weeks and now need the services of this list. I have a URL which connects to someone else's database system and returns what I have been told is "compact XML." Having never heard of it before I was curious. Submitting the URL in a browser I get back a ton of data that is lumped together on the screen. A view source shows something else. The first 2 lines are tag-like and the data starts on the third line. That line contains this: NAME ADDRESS PHONE The above data is substituted to make this easier and the line really has about 80 fields. Each field is separated by a TAB character. Then all the following lines look like this: (several hundred lines) Fred 1123 Main Street 555-1212 This goes on until the end where there is another ending-tag-like tag on the very last line. Here is what I need to be able to do AUTOMATICALLY: 1)Submit the URL (I can get the data back by using urllib.urlopen(url) ) 2)Parse the data to remove the first 2 lines and the last line. 3)Parse each line to remove the start and end tags. 4)Make a connection to an ODBC data source on the same PC. 5)Delete all the data in a table. 6)'Pour' all the new data into the appropriate fields in the table 7)Send me an email letting me know the status of the job - number or records, etc. That's it! I have been able to do some of the things at the winPython prompt but not sure how to proceed with the details of make this into a stand-alone py file that handles all these things. My thought would be to CHRON this to have it run at night to update my data. So...thoughts, comments, directions... Don't want someone to DO it for me but I think I need some basic help in putting the pieces together. If its too much to ask of this list, I would like to know that too. Thanks! Allen _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From dyoo@hkn.eecs.berkeley.edu Thu Jun 14 16:28:40 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 14 Jun 2001 08:28:40 -0700 (PDT) Subject: [Tutor] Threads.... Unhandle my Exception you Feind! (fwd) In-Reply-To: Message-ID: On Thu, 14 Jun 2001, Daniel Yoo wrote: > import win32com.client > import random > import time > import string > import thread > > engine=win32com.client.Dispatch("DAO.DBEngine.35") > db=engine.OpenDatabase(r"windowsdesktopterror.mdb") > > > ## Function write() writes a list to the database > def write(inputtage): > if db==None: > print 'el vomito' > db.Execute("insert into data values(%f, '%s')" % inputtage) > return 'ok' > > if __name__=='__main__': > tik_tok=time.time() > surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) > the_madness=(tik_tok, surprize) > thread.start_new_thread(write,(the_madness,)) Let's explore the problem further. Can you try this program?: ### import win32com.client import random import time import string engine=win32com.client.Dispatch("DAO.DBEngine.35") db=engine.OpenDatabase(r"windowsdesktopterror.mdb") if db==None: print 'el vomito 1' ## Function write() writes a list to the database def write(inputtage): if db==None: print 'el vomito 2' db.Execute("insert into data values(%f, '%s')" % inputtage) return 'ok' if __name__=='__main__': tik_tok=time.time() surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) the_madness=(tik_tok, surprize) write(the_madness) ### If this program says "el vomito 1', then it's definitely because of: db=engine.OpenDatabase(r"\\windows\\desktop\\terror.mdb") and that's something you can fix. Otherwise, if everything works, then it must have something to do with way threads work. I think I sorta understand what's going on, but the results of this experiment will make me more sure. Let's try this experiment and see what we get from it. Hope this helps! From pobrien@orbtech.com Thu Jun 14 16:42:06 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Thu, 14 Jun 2001 10:42:06 -0500 Subject: [Tutor] a couple of ideas I've been bouncing around In-Reply-To: Message-ID: I like both of these ideas. Maybe there is a way to combine them. Perhaps the only difference is the Trivial Pursuit version gives the answer and the Certification version withholds the answer. The pyDoc module shows what you can do to make the python interpreter even more interactive in terms of presenting a lot of text and responding to requests for information. Perhaps we could piggyback that module and create an interactive trivia/tutor/testing/certification module. I bet the Edu Sig folks might be interested in this as well. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Rob Andrews Sent: Thursday, June 14, 2001 9:58 AM To: tutor@python.org Subject: [Tutor] a couple of ideas I've been bouncing around In my ongoing quest for novel (twisted?) ways to add even more color to the Python universe, I've come up with a few more ideas. I picked up Trivial Pursuit Genus 5 the other day and thought it would be interesting to produce a Python module for it, essentially a collection of questions and answers about Python, broken down by general category (e.g., "Python Mythology", "Data Structures", "Python History", etc.) using a color scheme compatible with the one Trivial Pursuit uses. This could be printed up on some nice card stock and actually used with the boxed game set. The second idea is an actual test. Brainbench (http://www.brainbench.com) offers a $19.95 certification in Python 1.5. With all the keen, experienced minds and nearly inexhaustible number of questions archived on this list, we should be able to come up with a nice test that generates a brief, meaningful report on how one performed on it. """You were strong enough to tutor another person in the areas of "strings" and "exception handling". You seemed competent in "flow control" and "sockets". You should study more on "OOP" and "embedding". You answered 87% correctly, soundly passing Python Tutor Certification.""" I think anything we do along these general lines would help provide another great learning tool and a healthy bit of fun all around. Rob "Perl is worse than Python because people wanted it worse." Larry Wall (Creator of Perl), 14 Oct 1998 Useless Python: http://www.lowerstandard.com/python/ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From alan.gauld@bt.com Thu Jun 14 16:50:22 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 14 Jun 2001 16:50:22 +0100 Subject: [Tutor] Get it, Parse it, Dump it.... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D81F@mbtlipnt02.btlabs.bt.co.uk> > From the winPython interpreter, one line at a time, I do this: > >>> import urllib > >>> x=urllib.urlopen("http://site.that.has.the.data/search?etc=stuff") > >>> print x.readlines() > > And this shows everything on one LONG line > ... > I have been able to use string.split to break the line into a > list on the TAB character. > > Not sure how to go about building this into something that > can run on its own instead of the command prompt. OK the easy bit first ;-) Just open a new empty text file and type in the commands that you entered at the >>> prompt. ie the ast line would look like: print x.readlines() insert as the first line: #! /usr/bin/env python Save the file as fetchdata.py or whatever and make it executable and then run it. (I'm assuming since you mentioned chron(cron?) that you are on a Linux/Unix platform...) If you are on windows(coz you mention OCDB below) you don't need the special first line above and can just save the file and then run it by double clicking in windoze exploder. > Also need to know how to connect to and talk to my ODBC > defined database (Access2000) and then take the fields, > one line at a time, and insert them > into the DB table. For that you need some SQL - do you know SQL? If not then I think Access has some tools that generate it for you and you could copy it into your program but its really better if you learn basic SQL - its easy enough... > I am using Zope so if there is a way to build this into a > script or external method and call it from Zope that My limited understanding of Zope says that if you wrap the code as a function inside the file then you can call it from Zope. I'm sure theres some extra magic but ... To create a function just do: def doit(): # add your lines here all indented by a constant amount The Zope URL will then be: http:// Message-ID: On Thu, 14 Jun 2001 kromag@nsacom.net wrote: > ----------------end dbwrong.py--------------- > > > >pythonw -u dbwrong.py > el vomito 2 > Unhandled exception in thread: > Traceback (most recent call last): > File "dbwrong.py", line 17, in write > db.Execute("insert into data values(%f, '%s')" % inputtage) > AttributeError: 'None' object has no attribute 'Execute' > >Exit code: 0 > > > Thread it is! :-) Ah ha! Now I can make a good guess at what's happening. Here's the guess: when the main thread (the main program) gets to the end of the program, it finishes. However, the program still needs to wait until the newly-spawned thread finishes. That's ok so far. The big problem is: what happens to all the variables created from the main thread, after the thread dies? In particular, what happens to our 'db' variable? What I think is happening is that Python believes we won't be needing 'db' anymore, so it sets it back to None. Let's look at the program again, and this theory might gain plausibility: > engine=win32com.client.Dispatch("DAO.DBEngine.35") > db=engine.OpenDatabase(r"windowsdesktopterror.mdb") > if db==None: ## This was added since > print 'el vomito 1' ## last posting! > > > ## Function write() writes a list to the database > def write(inputtage): > if db==None: > print 'el vomito 2' ## As was this... > db.Execute("insert into data values(%f, '%s')" % inputtage) > return 'ok' > > if __name__=='__main__': > tik_tok=time.time() > surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) > the_madness=(tik_tok, surprize) > thread.start_new_thread(write,(the_madness,)) I'll pretend to be the Python system. "We've just started the new thread. Hey, we're done with the main thread! I'll be nice and clean up the resources my user doesn't need. Let's see... we don't need 'engine' anymore. Ok, let's toss that. How about 'db'? I don't see that anyone needs it, since write() is in its own little black bock. Ok, let's toss that aside too!" Of course, I could be really wrong about this, but this is my best guess. The fix is to convince Python that it really should keep 'db': let's include it as another argument to the write() function. Here's an edit of your program: ### import win32com.client import random import time import string import thread ## Function write() writes a list to the database def write(db, inputtage): if db==None: print 'el vomito 2' ## As was this... db.Execute("insert into data values(%f, '%s')" % inputtage) return 'ok' if __name__=='__main__': engine = win32com.client.Dispatch("DAO.DBEngine.35") db = engine.OpenDatabase(r"windowsdesktopterror.mdb") tik_tok = time.time() surprize = random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble']) the_madness = (tik_tok, surprize) thread.start_new_thread(write,(db, the_madness)) ### The way that this works is that when the main thread is done, and when it sees if 'db' can be recycled for its bits, the new thread can step in and say "Gimme!", and maintain db for its own use. It also avoids global variables. I'll cross my fingers about this one... *grin* Good luck! From tbrauch@mindless.com Fri Jun 15 00:03:07 2001 From: tbrauch@mindless.com (Timothy M. Brauch) Date: Thu, 14 Jun 2001 19:03:07 -0400 Subject: [Tutor] Taking Mark Lutz's training course References: Message-ID: <3B2942AB.C13CC8E2@mindless.com> People have written: > > > I have yet to find a college in the midwest that even teaches Python. > > *sigh* > > I actually tried to do a small "Introduction to Python" session in > Berkeley once. What a disaster! The problem was that the language was so > obvious, so simple, that I didn't need to say anything... *grin* > > Truthfully, I'd need to improve my speaking skills before tackling > something like that. Centre College in Danville Kentucky (where I currently attend) offers Python in the intro computer science class. C/C++ used to be offered, but too many people needed a cs class for their majors (like biology majors) and they couldn't catch on to C/C++ ideas as easily. So, we start with Python and a little post script and SQL (using Gadfly), go to MIPS assembly langauge, then Java and/or C/C++ then C/C++ and/or Java (it depends which sequence they are currently going, they are offered every other year I think). Also, we can learn Maple or Mathematica, if we are so inclined. - Tim From guess-who@kevin-masako.com Fri Jun 15 01:48:49 2001 From: guess-who@kevin-masako.com (Kevin & Masako Ollivier) Date: Thu, 14 Jun 2001 20:48:49 -0400 Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around Message-ID: <011201c0f534$f1a809c0$6401a8c0@cox.rr.com> Hi Patrick and Rob, I also like both of your ideas! (BTW, thanks Patrick for sharing this with the edu-sig list! I had not realized there was also a Tutor list!) Building on the ideas you presented, what about an software tool (possibly an "enhanced" version of IDLE?) that gives learners a set of successively harder programming tasks? At any point, the learner can jump to a virtual "help center" and view tutorials, the Python references, FAQs/trivia, or even be given a way to ask a question on the lists. As the learner successfully complete the tasks given to them, the software will keep a record and let them know how far they are towards "mastery." (Of course, true mastery comes only with experience, but it's a start!) I think it has elements of everything discussed thus far, trivia, tutor, and testing. While I'm not sure how we could "officially" certify people who complete the training, we can at least give them a list of all the skills they've gathered over the course of the training, along with when they were last assessed. I think making "real-world tasks" would help increase motivation and give them examples of what Python is typically used for. The more real it seems, the more it will be part-game and part-edusoft I think. If we did it well enough, it could even lead to a finished software product, which is at least as good as a certificate IMHO! What do you all think? Kevin Ollivier -------------------------------------------- Reply-To: From: "Patrick K. O'Brien" To: Cc: "Python Edu SIG" Date: Thu, 14 Jun 2001 10:42:06 -0500 Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around I like both of these ideas. Maybe there is a way to combine them. Perhaps the only difference is the Trivial Pursuit version gives the answer and the Certification version withholds the answer. The pyDoc module shows what you can do to make the python interpreter even more interactive in terms of presenting a lot of text and responding to requests for information. Perhaps we could piggyback that module and create an interactive trivia/tutor/testing/certification module. I bet the Edu Sig folks might be interested in this as well. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Rob Andrews Sent: Thursday, June 14, 2001 9:58 AM To: tutor@python.org Subject: [Tutor] a couple of ideas I've been bouncing around In my ongoing quest for novel (twisted?) ways to add even more color to the Python universe, I've come up with a few more ideas. I picked up Trivial Pursuit Genus 5 the other day and thought it would be interesting to produce a Python module for it, essentially a collection of questions and answers about Python, broken down by general category (e.g., "Python Mythology", "Data Structures", "Python History", etc.) using a color scheme compatible with the one Trivial Pursuit uses. This could be printed up on some nice card stock and actually used with the boxed game set. The second idea is an actual test. Brainbench (http://www.brainbench.com) offers a $19.95 certification in Python 1.5. With all the keen, experienced minds and nearly inexhaustible number of questions archived on this list, we should be able to come up with a nice test that generates a brief, meaningful report on how one performed on it. """You were strong enough to tutor another person in the areas of "strings" and "exception handling". You seemed competent in "flow control" and "sockets". You should study more on "OOP" and "embedding". You answered 87% correctly, soundly passing Python Tutor Certification.""" I think anything we do along these general lines would help provide another great learning tool and a healthy bit of fun all around. Rob "Perl is worse than Python because people wanted it worse." Larry Wall (Creator of Perl), 14 Oct 1998 Useless Python: http://www.lowerstandard.com/python/ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From rob@jam.rr.com Fri Jun 15 02:56:51 2001 From: rob@jam.rr.com (Rob Andrews) Date: Thu, 14 Jun 2001 20:56:51 -0500 Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around In-Reply-To: <011201c0f534$f1a809c0$6401a8c0@cox.rr.com> Message-ID: # # Hi Patrick and Rob, # # I also like both of your ideas! (BTW, thanks Patrick for sharing this with # the edu-sig list! I had not realized there was also a Tutor list!) # The Tutor list is great! I can't easily think of a more helpful, decent group of people. And some of the answers to newbie coding questions could easily be quoted verbatim in documentation. # Building on the ideas you presented, what about an software tool (possibly # an "enhanced" version of IDLE?) that gives learners a set of successively # harder programming tasks? At any point, the learner can jump to a virtual # "help center" and view tutorials, the Python references, FAQs/trivia, or # even be given a way to ask a question on the lists. As the learner # successfully complete the tasks given to them, the software will keep a # record and let them know how far they are towards "mastery." (Of course, # true mastery comes only with experience, but it's a start!) I think it has # elements of everything discussed thus far, trivia, tutor, and # testing. While # I'm not sure how we could "officially" certify people who complete the # training, we can at least give them a list of all the skills they've # gathered over the course of the training, along with when they were last # assessed. # # I think making "real-world tasks" would help increase motivation and give # them examples of what Python is typically used for. The more real # it seems, # the more it will be part-game and part-edusoft I think. If we did it well # enough, it could even lead to a finished software product, which # is at least # as good as a certificate IMHO! # # What do you all think? # # Kevin Ollivier # Sounds quite interesting, although quite far beyond my skill level. There are probably lots of odd games we could develop using curses, pygame, etc. to reinforce learning. If we came up with enough components, I could even see a Python Learning Lab on sourceforge or similar (or on Useless Python heehee). Rob "Perl is worse than Python because people wanted it worse." Larry Wall (Creator of Perl), 14 Oct 1998 Useless Python: http://www.lowerstandard.com/python/ From guess-who@kevin-masako.com Fri Jun 15 04:12:55 2001 From: guess-who@kevin-masako.com (Kevin & Masako Ollivier) Date: Thu, 14 Jun 2001 23:12:55 -0400 Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around References: Message-ID: <013a01c0f549$12f77980$6401a8c0@cox.rr.com> ----- Original Message ----- From: "Rob Andrews" To: "Kevin & Masako Ollivier" ; ; Sent: Thursday, June 14, 2001 9:56 PM Subject: RE: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around > # > # Hi Patrick and Rob, > # > # I also like both of your ideas! (BTW, thanks Patrick for sharing this with > # the edu-sig list! I had not realized there was also a Tutor list!) > # > > The Tutor list is great! I can't easily think of a more helpful, decent > group of people. And some of the answers to newbie coding questions could > easily be quoted verbatim in documentation. Actually, I signed up to the Python edu-sig list just yesterday because I was thinking about the very topic you were discussing. I had always wanted to be able to teach family and friends who are computer users Python simply because I often find myself writing little scripts to automate everyday, repetitive tasks I do on the computer. I was hoping to bounce some ideas back and forth through the list, and the same day I sign up I'm getting my wish! =) The classroom courses I've taken and books I've read almost seem to take all the fun out of programming, and focus on learning syntax, not problem solving. I remember in my first C programming class, one of the students whispered to his friend "So when are we going to start learning how to program GAMES?" That stuck with me. They didn't see how the lessons they were learning could be used to create games. And if they don't see that (in other words, they didn't see how what they were learning could accomplish their goal), what are they going to take out of the class? If it's anything like the Trig I learned... Nothing. =) > # Building on the ideas you presented, what about an software tool (possibly > # an "enhanced" version of IDLE?) that gives learners a set of successively > # harder programming tasks? At any point, the learner can jump to a virtual > # "help center" and view tutorials, the Python references, FAQs/trivia, or > # even be given a way to ask a question on the lists. As the learner > # successfully complete the tasks given to them, the software will keep a > # record and let them know how far they are towards "mastery." (Of course, > # true mastery comes only with experience, but it's a start!) I think it has > # elements of everything discussed thus far, trivia, tutor, and > # testing. While > # I'm not sure how we could "officially" certify people who complete the > # training, we can at least give them a list of all the skills they've > # gathered over the course of the training, along with when they were last > # assessed. > # > # I think making "real-world tasks" would help increase motivation and give > # them examples of what Python is typically used for. The more real > # it seems, > # the more it will be part-game and part-edusoft I think. If we did it well > # enough, it could even lead to a finished software product, which > # is at least > # as good as a certificate IMHO! > # > # What do you all think? > # > # Kevin Ollivier > # > > Sounds quite interesting, although quite far beyond my skill level. There > are probably lots of odd games we could develop using curses, pygame, etc. > to reinforce learning. If we came up with enough components, I could even > see a Python Learning Lab on sourceforge or similar (or on Useless Python > heehee). Some of it is beyond my skill level too. Of course I believe you don't learn new skills until you need them, so I like to give myself a challenge every now and then. =) At the same time, there's quite a bit of work, programming and non-programming, to go around! The tutorials would be quite a bit of work, and then there's Trivial Python (errr... different name maybe?), and if we're serious about the real-world scenarios then someone would have to drum those up too. Like good object-oriented programmers, we could develop each component separately then in the end integrate them into the software. The Useless Python Learning Lab, huh? =) I have to admit the thing I don't like about SourceForge is that it sometimes can be dead slow, or down at times. Thanks, Kevin From fallen@leveltwo.com Fri Jun 15 17:34:46 2001 From: fallen@leveltwo.com (Fred Allen) Date: Fri, 15 Jun 2001 09:34:46 -0700 Subject: [Tutor] PYTHONDOCS & Html Documentation Message-ID: <4BB02C541824D311921600902765DB7B445602@LTISERVER> Fellows: I have modified my 'site.py' file with Guido's elegant redefinition of __builtin__.help, posted on Edu-sig. When, from Python's interactive screen, I invoke help for, say, 'keywords', behavior accords with expectation...i.e., a list of keywords is presented. But, when I invoke it for one of the keywords, say, 'lambda', I receive the following informative, courteous and well phrased message: “Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location.” That message's suggestion made sense, so I followed it. That is, I downloaded Python 2.1 HTML Documentation (15 April 2001), a 2008 Kb ZIP file and extracted its 's contents into C:\Python21\Docs\Html, yielding 10 subdirectories, viz: api, dist, doc, ext, icons, inst, lib, mac, ref, and tut. I assume, but am by no means sure, this was the intention of the error messages “installed.” I next dutifully created the PYTHONDOCS environment variable (under Windows 2000), ultimately evaluated thus: PYTHONDOCS=C:\Python21\Docs\Html;C:\Python21\Docs\Html\api;C:\Python21\D ocs\Html\dist;C:\Python21\Docs\Html\doc;C:\Python21\Docs\Html\ext;C:\Pyt hon21\Docs\Html\icons;C:\Python21\Docs\Html\inst;C:\Python21\Docs\Html\l ib;C:\Python21\Docs\Html\ref;C:\Python21\Docs\Html\tut I've also tried assigning PYTHONDOCS only the value “C:\Python21\Docs\Html”, the name of the expanded documentations top directory, but it functioned as initially. So does it now, despite the environment variable's now explicitly citing every subdirectory. I attempted expressing PYTHONDOCS directories in Pythonese (e.g., as arrays of strings). All to no avail. If I'm alone in this problem, I'm embarrassed, but consider that worthwhile in exchange for learning what I'm doing or have done wrong. With thanks in advance for any's help, I am, Gratefully, Fred Allen From dyoo@hkn.eecs.berkeley.edu Fri Jun 15 19:27:16 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Fri, 15 Jun 2001 11:27:16 -0700 (PDT) Subject: [Tutor] PYTHONDOCS & Html Documentation In-Reply-To: <4BB02C541824D311921600902765DB7B445602@LTISERVER> Message-ID: On Fri, 15 Jun 2001, Fred Allen wrote: > downloaded Python 2.1 HTML Documentation (15 April 2001), a 2008 Kb ZIP > file and extracted its 's contents into C:\Python21\Docs\Html, yielding > 10 subdirectories, viz: api, dist, doc, ext, icons, inst, lib, mac, ref, > and tut. I assume, but am by no means sure, this was the intention of Sounds good! Your PYTHONDOCS variable should then say: C:\Python21\Docs\Html > I've also tried assigning PYTHONDOCS only the value > =93C:\Python21\Docs\Html=94, the name of the expanded documentations top Oh. > So does it now, despite the environment variable's now explicitly > citing every subdirectory. I attempted expressing PYTHONDOCS > directories in Pythonese (e.g., as arrays of strings). All to no > avail. Ah! Ok, you won't need to put every directory; the base directory is the only one you'll need. I think that pydoc expects PYTHONDOCS to name only one directory. Let me check. Within the pydoc source code, there's one place where pydoc uses PYTHONDOCS: ### ## within pydoc.Helper.__init__ for dir in [os.environ.get('PYTHONDOCS'), # [dyoo: complicated paths removed to make # explanation more simple] if dir and os.path.isdir(os.path.join(dir, 'lib')): self.docdir =3D dir ### Basically, the code here says that it expects PYTHONDOCS to name a single base directory --- it'll attach the subdirectory name 'lib' to it, and then pydoc will be happy. So the problem was adding too much to PYTHONDOCS. Hope this helps! From phil.bertram@clear.net.nz Fri Jun 15 00:53:43 2001 From: phil.bertram@clear.net.nz (Phil Bertram) Date: Fri, 15 Jun 2001 11:53:43 +1200 Subject: [Tutor] Extending PythonWin as a quick and dirty GUI Message-ID: <000301c0f5d0$4c34b820$363661cb@pf05nt.bayernz.co.nz> Hi all, I am trying to develop an app that uses a Tkinter GUI. I am developing the code in 'text' mode and will hook in my GUI later. I am under the impression that PythonWin can be simply and quickly extended and used as a GUI for python code. Eg. One is able to add a couple of menu items to PythonWin, run your code from these menus, print to the PythonWin interactive window etc etc. I would like to do this during development and when things are working, then spend the time writing the proper GUI. Is this possible with PythonWin ? PB From phil.bertram@clear.net.nz Fri Jun 15 23:53:24 2001 From: phil.bertram@clear.net.nz (Phil Bertram) Date: Sat, 16 Jun 2001 10:53:24 +1200 Subject: [Tutor] Option of passing sequences are arguments Message-ID: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz> Is it possible to unpack a sequence to fill arguments. I have been playing around with *args type aruments but can't seem to get it to work. Eg I would like to define a class so that it can be called as follows m = MyObject(arg1,arg2,arg3) or args=(arg1,arg2,arg3) x=MyObject(args) Phil B From kalle@gnupung.net Sat Jun 16 00:31:11 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Sat, 16 Jun 2001 01:31:11 +0200 Subject: [Tutor] Option of passing sequences are arguments In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>; from phil.bertram@clear.net.nz on Sat, Jun 16, 2001 at 10:53:24AM +1200 References: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz> Message-ID: <20010616013111.A3960@gandalf> Sez Phil Bertram: > I would like to define a class so that it can be called as follows > > m = MyObject(arg1,arg2,arg3) > > or > > args=(arg1,arg2,arg3) > x=MyObject(args) Python 2.1 (#1, Jun 15 2001, 00:08:24) [GCC 2.95.4 20010604 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> def f(*args): ... print args ... >>> args = (1,2,3) >>> f(1,2,3) (1, 2, 3) >>> f(args) ((1, 2, 3),) >>> f(*args) # This only works in 2.1 (2.0?) and later (1, 2, 3) >>> apply(f, args) (1, 2, 3) >>> Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From j_f9@yahoo.com Sat Jun 16 04:12:54 2001 From: j_f9@yahoo.com (F. Tourigny) Date: Fri, 15 Jun 2001 20:12:54 -0700 (PDT) Subject: [Tutor] Looking for an HTMLgen table example In-Reply-To: Message-ID: <20010616031254.72362.qmail@web14506.mail.yahoo.com> I'm looking for a simple example of how to convert ASCII strings into an html table with HTMLgen and, more specifically, how to append rows, and put data into cells. I'm just starting with Python and the HTMLcalendar.py and barchart.py demo modules coming with the distribution are way over my head at this point. (They're proving to be a good read, though.) Greetings, Frederic __________________________________________________ Do You Yahoo!? Spot the hottest trends in music, movies, and more. http://buzz.yahoo.com/ From jstanley@start.com.au Sat Jun 16 06:37:40 2001 From: jstanley@start.com.au (Jordan Stanley) Date: Sat, 16 Jun 2001 15:37:40 +1000 Subject: [Tutor] win98se path Message-ID: __________________________________________________________________ Get your free Australian email account at http://www.start.com.au From jstanley@start.com.au Sat Jun 16 06:37:27 2001 From: jstanley@start.com.au (Jordan Stanley) Date: Sat, 16 Jun 2001 15:37:27 +1000 Subject: [Tutor] win98se path Message-ID: __________________________________________________________________ Get your free Australian email account at http://www.start.com.au From jstanley@start.com.au Sat Jun 16 06:39:20 2001 From: jstanley@start.com.au (Jordan Stanley) Date: Sat, 16 Jun 2001 15:39:20 +1000 Subject: [Tutor] win98 path Message-ID: with a lot of the examples i have the path is for linux which i dont have installed at the moment. when it says on the first line #/usr/src et cetera in windblows do i change that to #/c:/python21/ ??? thanks in advance Jordan mailto:jstanley@start.com.au __________________________________________________________________ Get your free Australian email account at http://www.start.com.au From ak@silmarill.org Sat Jun 16 07:07:12 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Sat, 16 Jun 2001 02:07:12 -0400 Subject: [Tutor] win98 path In-Reply-To: <"from jstanley"@start.com.au> References: Message-ID: <20010616020712.A21199@sill.silmarill.org> On Sat, Jun 16, 2001 at 03:39:20PM +1000, Jordan Stanley wrote: > with a lot of the examples i have the path is for linux which i dont > have installed at the moment. > > when it says on the first line #/usr/src et cetera > > in windblows do i change that to #/c:/python21/ ??? > > thanks in advance > > Jordan > > mailto:jstanley@start.com.au I don't have windows installed but I think you either have #!C:\path_to_python OR don't have anything there, and windows just knows it's python source because file is named .py. > > > __________________________________________________________________ > Get your free Australian email account at http://www.start.com.au > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Lucifer Sam Siam cat Always sitting by your side Always by your side That cat's something I can't explain - Syd From wheelege@tsn.cc Sat Jun 16 08:08:59 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 16 Jun 2001 17:08:59 +1000 Subject: [Tutor] win98 path References: Message-ID: <009101c0f633$3772a880$0200a8c0@ACE> > with a lot of the examples i have the path is for linux which i dont > have installed at the moment. > > when it says on the first line #/usr/src et cetera > > in windblows do i change that to #/c:/python21/ ??? > It really depends on what your trying to do. On Linux, that line will make it a python scipt. However, windows uses extensions to determine file type. If you installed python correctly then this will be already done for you, and just double-clicking on a python script will run it in a dos-window. If this already happens, and the box opens and closes too fast, try adding a raw_input('Press any key to continue...') to the end of your script. If in fact you are looking to set up your PYTHONPATH environment variable then that's different again. Is any of that what your looking for? Glen. From toodles@yifan.net Sat Jun 16 08:22:57 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Sat, 16 Jun 2001 15:22:57 +0800 Subject: [Tutor] randomness Message-ID: Hi folks What's a good way to generate a random unique file name? I can't use os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with Python 2.1 I could only think of this: import os,random files=os.listdir('threadhtml') filename='' while not filename: n=random.randint(0,100000) if not '%i.html' in files: filename='%i.html' But it seems a bit yucky...can someone shed any light on the matter? Thanks, Andrew From wheelege@tsn.cc Sat Jun 16 08:22:10 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 16 Jun 2001 17:22:10 +1000 Subject: [Tutor] randomness References: Message-ID: <009d01c0f635$0f567dc0$0200a8c0@ACE> > Hi folks > > What's a good way to generate a random unique file name? I can't use > os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with > Python 2.1 I could only think of this: > > import os,random > > files=os.listdir('threadhtml') > filename='' > while not filename: > n=random.randint(0,100000) > if not '%i.html' in files: > filename='%i.html' > > But it seems a bit yucky...can someone shed any light on the matter? > Hmmm, well I just used the string modules' predefined string.letters variable and split it into a list, then did a random number of random.choice() grabs from it and shoved them in a filename. Be sure to check if the file already exists. I think your code does not do 'unique file name'-s as you put it :) Glen. From steve@mercury.in.cqsl.com Sat Jun 16 08:40:02 2001 From: steve@mercury.in.cqsl.com (lonetwin@yahoo.com) Date: Sat, 16 Jun 2001 13:10:02 +0530 (IST) Subject: [Tutor] randomness In-Reply-To: Message-ID: Hi There, On Sat, 16 Jun 2001, Andrew Wilkins wrote: >Hi folks > >What's a good way to generate a random unique file name? I can't use >os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with >Python 2.1 I could only think of this: > >import os,random > >files=os.listdir('threadhtml') >filename='' >while not filename: > n=random.randint(0,100000) > if not '%i.html' in files: > filename='%i.html' > >But it seems a bit yucky...can someone shed any light on the matter? How 'bout filename = "tmpfile%d.html" % os.getpid() I've seen some *nix proggys do that, U cud also save the pid so that U can delete the file later..... Just a suggestion Peace Steve -- |||||||||||||||||||||| |||||||||#####|||||||| ||||||||#######||||||| ||||||||# O O #||||||| ||||||||#\ ~ /#||||||| ||||||##||\_/||##||||| |||||#||||||||||##|||| ||||#||||||||||||##||| ||||#|||||||||||||##|| |||/\##|||||||||##/\|| |/ \#########/ \ |\ \#######/ / ||\____/#######\____/| ===================================== Hello. Just walk along and try NOT to think about your INTESTINES being almost FORTY YARDS LONG!! ==================================== From toodles@yifan.net Sat Jun 16 08:38:37 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Sat, 16 Jun 2001 15:38:37 +0800 Subject: [Tutor] randomness In-Reply-To: Message-ID: > import os,random > files=os.listdir('threadhtml') filename='' while not filename: n=random.randint(0,100000) if not '%i.html'%n in files: filename='%i.html'%n I oughta check it before sending... > > But it seems a bit yucky...can someone shed any light on the matter? > > Thanks, > > Andrew > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From ak@silmarill.org Sat Jun 16 08:33:26 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Sat, 16 Jun 2001 03:33:26 -0400 Subject: [Tutor] randomness In-Reply-To: <"from toodles"@yifan.net> References: Message-ID: <20010616033326.A22291@sill.silmarill.org> On Sat, Jun 16, 2001 at 03:22:57PM +0800, Andrew Wilkins wrote: > Hi folks > > What's a good way to generate a random unique file name? I can't use > os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with 6.19 tempfile -- Generate temporary file names This module generates temporary file names. It is not Unix specific, but it may require some help on non-Unix systems. [snip] -- I'll give you anything, everything if you want things - Syd From tutor@python.org Sat Jun 16 08:44:08 2001 From: tutor@python.org (Tim Peters) Date: Sat, 16 Jun 2001 03:44:08 -0400 Subject: [Tutor] randomness In-Reply-To: Message-ID: [Andrew Wilkins] > What's a good way to generate a random unique file name? ... The bad news is that it's surprisingly difficult to do this "correctly" across platforms. The good news is that's why Python does it for you: look in the Library Reference Manual for the standard tempfile.py module. tempfile.TemporaryFile() is the best function to use from that, because it returns an open file object as secure as possible against attacks. tempfile.mktemp() can be used to get just a path name that didn't exist at the time you called mktemp(), but it's impossible then to guarantee that some other process won't create a file with that name before you get around to doing so. Python plays several tricks under the covers to make it exceedingly unlikely that another process will do so, but "guarantee" is a promise it can't make. Note that tempfile.py works fine on all platforms (whether Unix, Windows or Mac). From r.b.rigilink@chello.nl Sat Jun 16 08:57:50 2001 From: r.b.rigilink@chello.nl (Roeland Rengelink) Date: Sat, 16 Jun 2001 09:57:50 +0200 Subject: [Tutor] randomness References: Message-ID: <3B2B117E.F95A1DF0@chello.nl> Hi Andrew, My quick and dirty solution is usually to use time.time() in the filename. But if you're creating files in multiple threads (which I gather you're doing) there is of course an (exceedingly) small probabilty that files are created at the same moment. But then again, your code below theoretically suffers from the same problem (really, it does). This is really safe: file_creation_lock = Lock() class Filecreator: file_number = 0: def __call__(self): Filecreator.file_number += 1 return open('%6.6i.html' % Filecreator.file_number) filecreator = Filecreator() And in the thread: def run(): ... file_creation_lock.acquire() file = filecreator() file_creation_lock.release() ... But, then again, this may be overkill Hope this helps, Roeland Andrew Wilkins wrote: > > Hi folks > > What's a good way to generate a random unique file name? I can't use > os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with > Python 2.1 I could only think of this: > > import os,random > > files=os.listdir('threadhtml') > filename='' > while not filename: > n=random.randint(0,100000) > if not '%i.html' in files: > filename='%i.html' > > But it seems a bit yucky...can someone shed any light on the matter? > > Thanks, > > Andrew > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- r.b.rigilink@chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From arcege@speakeasy.net Sat Jun 16 12:14:56 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sat, 16 Jun 2001 07:14:56 -0400 (EDT) Subject: [Tutor] Looking for an HTMLgen table example In-Reply-To: <20010616031254.72362.qmail@web14506.mail.yahoo.com> from "F. Tourigny" at Jun 15, 2001 08:12:54 PM Message-ID: <200106161114.f5GBEuW01841@dsl092-074-184.bos1.dsl.speakeasy.net> F. Tourigny wrote > I'm looking for a simple example of how to convert > ASCII strings into an html table with HTMLgen and, > more specifically, how to append rows, and put data > into cells. I'm just starting with Python and the > HTMLcalendar.py and barchart.py demo modules coming > with the distribution are way over my head at this > point. (They're proving to be a good read, though.) I'd use the TableLite class; it is easier and more like the other classes in HTMLgen. Think about it like creating creating nested lists. >>> mylist = [] >>> for x in range(5): ... sublist = [] ... for y in range(5, 10): ... sublist.append( (x, y) ) ... mylist.append( sublist ) ... At this point you have a list of five sublists, each sublist will have five tuples of the coordinates. >>> print mylist [[(0, 5), (0, 6), (0, 7), (0, 8), (0, 9)], [(1, 5), (1, 6), (1, 7), (1, 8), (1, 9)], [(2, 5), (2, 6), (2, 7), (2, 8), (2, 9)], [(3, 5), (3, 6), (3, 7), (3, 8), (3, 9)], [(4, 5), (4, 6), (4, 7), (4, 8), (4, 9)]] Applying this to the HTMLgen, you can do something similar. >>> import HTMLgen >>> table = HTMLgen.TableLite() >>> for x in range(5): ... row = HTMLgen.TR() ... for y in range(5, 10): ... row.append( HTMLgen.TD( '%d, %d' % (x, y) ) ) # needs to be string ... table.append( row ) ... >>> print table
0, 50, 60, 70, 80, 9
1, 51, 61, 71, 81, 9
2, 52, 62, 72, 82, 9
3, 53, 63, 73, 83, 9
4, 54, 64, 74, 84, 9
>>> Captions are added as rows are and headers are added as columns. HTH, -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From lumbricus@gmx.net Sat Jun 16 14:58:42 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sat, 16 Jun 2001 15:58:42 +0200 Subject: [Tutor] randomness In-Reply-To: ; from steve@mercury.in.cqsl.com on Sat, Jun 16, 2001 at 01:10:02PM +0530 References: Message-ID: <20010616155842.A23710@Laplace.localdomain> On Sat, Jun 16, 2001 at 01:10:02PM +0530, lonetwin@yahoo.com wrote: > > Hi There, > Hello! > > > >What's a good way to generate a random unique file name? I can't use > >os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with > > How 'bout > filename = "tmpfile%d.html" % os.getpid() > I've seen some *nix proggys do that, U cud also save the pid so that U can delete the file > later..... > man symlink-attacks :-) > Just a suggestion > > Peace > Steve Grreetz J"o! -- Some people need a good imaginary cure for their painful imaginary ailment. From dyoo@hkn.eecs.berkeley.edu Sat Jun 16 19:59:22 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Sat, 16 Jun 2001 11:59:22 -0700 (PDT) Subject: [Tutor] win98 path In-Reply-To: Message-ID: On Sat, 16 Jun 2001, Jordan Stanley wrote: > with a lot of the examples i have the path is for linux which i dont > have installed at the moment. > > when it says on the first line #/usr/src et cetera > > in windblows do i change that to #/c:/python21/ ??? Hello Jordan, If you're on a Windows system, you don't need to worry about the first line. The line: ### #!/usr/local/bin/python ### is called a "magic line", and Unix systems look at it when we want to make our scripts executable as programs. Windows doesn't do executables this way (it does the .EXE way), so this top line isn't effective on a Windows system. By the way, which examples are you looking at? Talk to you later! From seedseven@home.nl Sat Jun 16 20:19:41 2001 From: seedseven@home.nl (Ingo) Date: Sat, 16 Jun 2001 21:19:41 +0200 Subject: [Tutor] Looking for an HTMLgen table example Message-ID: "F. Tourigny" wrote on 2001-06-16 05:12:54: > >I'm looking for a simple example of how to convert >ASCII strings into an html table with HTMLgen and, >more specifically, how to append rows, and put data >into cells. Don't know what HTMLgen is, but here is the result of my struggle with the same problem. Beware, it's only my third Python script and still a work in progress. Comments are welcome. http://members.home.nl/seedseven/words2table.zip Ingo -- Photography: http://members.home.nl/ingoogni/ POV-Ray: http://members.home.nl/seed7/ From jparlar@home.com Sat Jun 16 20:29:48 2001 From: jparlar@home.com (Jay Parlar) Date: Sat, 16 Jun 2001 15:29:48 -0400 Subject: [Tutor] Simple example that won't work! Message-ID: <20010616193516.YZPM7002.femail4.rdc1.on.home.com@jparlar> Hello to all my fellow Python lovers. I'm only learning Python right now (after a few years working with the comparatively terrible C/C++) and I am absolutely loving it. To learn the language, I am using Wesley Chun's "Core Python Programming". It's a very good book with some really good examples, but it's with one of the examples that I'm having difficulty. The example is a simple web-based example. All it does is retrieve an HTML document, and print out the first and last non- blank lines of the page. The error, though, occurs with the urlretrieve( ) call. When I call it, I get the following exception message: Traceback (most recent call last): File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ? download() File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download retval= urlretrieve(url)[0] File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve return _urlopener.retrieve(url, filename, reporthook, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve fp = self.open(url, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open return getattr(self, name)(url) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http h = httplib.HTTP(host) File "c:\program files\python20\lib\httplib.py", line 640, in __init__ self._conn = self._connection_class(host, port) File "c:\program files\python20\lib\httplib.py", line 330, in __init__ self._set_hostport(host, port) File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport port = int(host[i+1:]) ValueError: invalid literal for int(): My exact call was retval = urlretrieve(url)[0], where url is any web address. Now, the interesting thing is the code works fine on another computer it's been tried on, but no luck on mine. I'm running Win95b, with Python2.0 in the PythonWin environment. Any help would be GREATLY appreciated, Jay P. From j_f9@yahoo.com Sun Jun 17 00:01:54 2001 From: j_f9@yahoo.com (F. Tourigny) Date: Sat, 16 Jun 2001 16:01:54 -0700 (PDT) Subject: [Tutor] Looking for an HTMLgen table example In-Reply-To: Message-ID: <20010616230154.63839.qmail@web14503.mail.yahoo.com> And by passing arguments as they do in the HTMLcalendar.py example: table = HTMLgen.TableLite(cellpadding=6, cellspacing=2, border=3) ...I get a great table display. An amazing tool, HTMLgen. Thanks for helping me use it. > I'd use the TableLite class; it is easier and more > like the other classes in HTMLgen. Think about it > like creating creating nested lists. > > HTH, > -Arcege Greetings, Frederic __________________________________________________ Do You Yahoo!? Spot the hottest trends in music, movies, and more. http://buzz.yahoo.com/ From ak@silmarill.org Sun Jun 17 02:56:00 2001 From: ak@silmarill.org (ak@silmarill.org) Date: Sat, 16 Jun 2001 21:56:00 -0400 Subject: [Tutor] Simple example that won't work! In-Reply-To: <"from jparlar"@home.com> References: <20010616193516.YZPM7002.femail4.rdc1.on.home.com@jparlar> Message-ID: <20010616215600.A2779@sill.silmarill.org> On Sat, Jun 16, 2001 at 03:29:48PM -0400, Jay Parlar wrote: > > Hello to all my fellow Python lovers. I'm only learning Python right now (after a few years working with the comparatively > terrible C/C++) and I am absolutely loving it. To learn the language, I am using Wesley Chun's "Core Python Programming". > It's a very good book with some really good examples, but it's with one of the examples that I'm having difficulty. > > The example is a simple web-based example. All it does is retrieve an HTML document, and print out the first and last non- > blank lines of the page. The error, though, occurs with the urlretrieve( ) call. When I call it, I get the following exception > message: > > Traceback (most recent call last): > File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ? > download() > File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download > retval= urlretrieve(url)[0] > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve > return _urlopener.retrieve(url, filename, reporthook, data) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve > fp = self.open(url, data) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open > return getattr(self, name)(url) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http > h = httplib.HTTP(host) > File "c:\program files\python20\lib\httplib.py", line 640, in __init__ > self._conn = self._connection_class(host, port) > File "c:\program files\python20\lib\httplib.py", line 330, in __init__ > self._set_hostport(host, port) > File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport > port = int(host[i+1:]) > ValueError: invalid literal for int(): > > My exact call was > > retval = urlretrieve(url)[0], where url is any web address. > > Now, the interesting thing is the code works fine on another computer it's been tried on, but no luck on mine. I'm running > Win95b, with Python2.0 in the PythonWin environment. > > Any help would be GREATLY appreciated, > Jay P. The problem is that there was a bug in python where it'd accept (host,port) as an argument in some situation, and then it was fixed to accept ((host, port))- in other words, a tuple containing 2 elements instead of just two elements. This pops up all the time when you're using code written for before 2.0 I think. So, you can either fix that or use 1.5.2. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Lime and limpid green a second scene A fight between the blue you once knew - Syd From dyoo@hkn.eecs.berkeley.edu Sun Jun 17 04:55:43 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Sat, 16 Jun 2001 20:55:43 -0700 (PDT) Subject: [Tutor] win98 path (fwd) Message-ID: Dear Jordan, Hmmm... I haven't had a chance to look at Teach Yourself Python in 21 Hours, though the title seems a bit... hasty. *grin* I think you mean 21 days. In any case, you shouldn't have to worry too much about platform dependent stuff: the core of Python works the same on Windows, Unix, Mac, and anything else out there. Here's the syntax for the "Press enter to continue" thing: ### raw_input("Please press enter to continue.") ### If you put that line at the end, then Python will wait until you type enter. The real purpose of raw_input() is to allow users to type information for a program, but in a pinch, raw_input() also works well as something to stop the program from closing prematurely. Oh, finally, make sure to do the "Reply to All" thing on tutor email, so that others can answer your questions too. Good luck to you! Hope this helps. ---------- Forwarded message ---------- Date: Sun, 17 Jun 2001 9:58:04 +1000 From: Jordan Stanley To: "dyoo@hkn.eecs.berkeley.edu" Subject: Re: Re: [Tutor] win98 path i bought a book called sams teach yourself python in 21 hours. its quite good, except that it doesnt give win or *nix egs it just has generic code, and doesnt tell you how to stop the code just exiting straight away. someone else i think glen wheeler wrote me about it some thing like raw input "press any key to continue" but i dont know the correct syntax for that. thanks jordan By the way, which examples are you looking at? > > __________________________________________________________________ Get your free Australian email account at http://www.start.com.au From adam0@tsn.cc Sun Jun 17 06:51:41 2001 From: adam0@tsn.cc (Adam Gordon) Date: Sun, 17 Jun 2001 15:51:41 +1000 Subject: [Tutor] A (not so) simple question? Round Robin Message-ID: <001601c0f6f1$9886dba0$05a616ca@computer1> This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C0F745.66CBA4C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey Guys! I am just starting to learn python (after hearing my friend praise it = like a religion :) and thought I'd try out a few classic problems to = help the learning process. So, I went to Useless Python to check out the challenges, and then = went to the High School comp section. I went to the 2000 open = competition and looked for some fun problems. One which caught my eye = was a Round Robin problem - didn't look too hard or too easy. But, for the life of me I cannot do it! I've spent quite some time = mulling it over but still an elegant solution eludes me...here is a copy = of the problem as found on the website (here = http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml). ##start task Task 5 - Round Robin Description n teams are to play each other in a competition. In each round each team = plays exactly one other team. We wish to have as few rounds as possible. = Write a program which, given an even number n, produces a "draw table" = showing which team plays which team in each round. It is to take the = minimum possible number of rounds. If more than one such draw table is = possible your program may return whichever you wish.=20 For example here is an 4 player draw table=20 A B C D A 1 2 3 B 1 3 2 C 2 3 1 D 3 2 1 The letters represent the four teams, the numbers say which round each = pair of teams is playing.=20 Test Data Number of teams =20 4 =20 6 =20 8 =20 10 =20 Output Match the format of the output in the example above.=20 Where there is more than one "draw table" you may return whichever you = wish.=20 Constraints You may assume the input is even.=20 ##end task I apologize to anybody with a non-html friendly e-mail client for = spamming them with gibberish :) Thanks in advance, Adam. ------=_NextPart_000_0013_01C0F745.66CBA4C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
  Hey Guys!
 
  I am just starting to learn python (after hearing my friend = praise=20 it like a religion :) and thought I'd try out a few classic = problems to=20 help the learning process.
  So, I went to Useless Python to check out the challenges, = and then=20 went to the High School comp section.  I went to the 2000 open = competition=20 and looked for some fun problems.  One which caught my eye was a = Round=20 Robin problem - didn't look too hard or too easy.
  But, for the life of me I cannot do it!  I've spent = quite some=20 time mulling it over but still an elegant solution eludes me...here is a = copy of=20 the problem as found on the website (here http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml= ).
 
 
##start task

Task 5 - Round Robin

Description

n teams are to play each other in a competition. In each = round=20 each team plays exactly one other team. We wish to have as few rounds as = possible.=20

Write a program which, given an even number n, produces a = "draw table"=20 showing which team plays which team in each round. It is to take the = minimum=20 possible number of rounds. If more than one such draw table is possible = your=20 program may return whichever you wish.=20

For example here is an 4 player draw table

  A B C D
A   1 2 3
B 1   3 2
C 2 3   1
D 3 2 1

The letters represent the four teams, the numbers say which round = each pair=20 of teams is playing.=20

Test Data

Number of teams=20
4=20
6=20
8=20
10

Output

Match the format of the output in the example above.=20

Where there is more than one "draw table" you may return whichever = you wish.=20

Constraints

You may assume the input is even.
 
##end task
 
  I apologize to anybody with a non-html friendly e-mail = client for=20 spamming them with gibberish :)
 
  Thanks in advance,
  Adam.
------=_NextPart_000_0013_01C0F745.66CBA4C0-- From csmith@blakeschool.org Sun Jun 17 18:51:05 2001 From: csmith@blakeschool.org (Christopher Smith) Date: Sun, 17 Jun 2001 12:51:05 -0500 Subject: [Tutor] Mac 1011 error after installation In-Reply-To: References: Message-ID: Hello, I just tried to install the 2.1 Python on my Mac and have run into a problem. After a succcessful installation, when I try to run the IDE it quits with Mac error 1011 just after the splash screen goes away and the editor window appears. Has anyone else encountered this or know what might be wrong? Thanks for any help. /c From glingl@aon.at Sun Jun 17 21:03:02 2001 From: glingl@aon.at (Gregor Lingl) Date: Sun, 17 Jun 2001 22:03:02 +0200 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> Message-ID: <3B2D0CF6.5566EE8F@aon.at> --------------C754C59664FDB96DF7AC6849 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Adam Gordon schrieb: > Hey Guys! I am just starting to learn python (after hearing my > friend praise it like a religion :) and thought I'd try out a few > classic problems to help the learning process. So, I went to Useless > Python to check out the challenges, and then went to the High School > comp section. I went to the 2000 open competition and looked for some > fun problems. One which caught my eye was a Round Robin problem - > didn't look too hard or too easy. But, for the life of me I cannot do > it! I've spent quite some time mulling it over but still an elegant > solution eludes me...here is a copy of the problem as found on the > website (here > http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml). ##start > task > > Task 5 - Round Robin > > Description > > n teams are to play each other in a competition. In each round each > team plays exactly one other team. We wish to have as few rounds as > possible. > > Write a program which, given an even number n, produces a "draw table" > showing which team plays which team in each round. It is to take the > minimum possible number of rounds. If more than one such draw table is > possible your program may return whichever you wish. > > For example here is an 4 player draw table > > A B C D > A 1 2 3 > B 1 3 2 > C 2 3 1 > D 3 2 1 > > The letters represent the four teams, the numbers say which round each > pair of teams is playing. > > Test Data > > Number of teams 4 6 8 10 > > Output > > Match the format of the output in the example above. > > Where there is more than one "draw table" you may return whichever you > wish. > > Constraints > > You may assume the input is even. ##end task I apologize to anybody > with a non-html friendly e-mail client for spamming them with > gibberish :) Thanks in advance, Adam. Here is a quick and dirty solution. Not very Pythonesque, more a classical approach. Take it as a challenge for Pythonistas to find a more *beautiful* one. ( http://www.lowerstandard.com/python/beautycontest.txt ) def roundrobin(n): # setup table global table table = [range(n)] for i in range(1,n): row = [i] while len(row)  

Adam Gordon schrieb:

  Hey Guys!   I am just starting to learn python (after hearing my friend praise it like a religion :) and thought I'd try out a few classic problems to help the learning process.  So, I went to Useless Python to check out the challenges, and then went to the High School comp section.  I went to the 2000 open competition and looked for some fun problems.  One which caught my eye was a Round Robin problem - didn't look too hard or too easy.  But, for the life of me I cannot do it!  I've spent quite some time mulling it over but still an elegant solution eludes me...here is a copy of the problem as found on the website (here http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml).  ##start task

Task 5 - Round Robin

Description

n teams are to play each other in a competition. In each round each team plays exactly one other team. We wish to have as few rounds as possible.

Write a program which, given an even number n, produces a "draw table" showing which team plays which team in each round. It is to take the minimum possible number of rounds. If more than one such draw table is possible your program may return whichever you wish.

For example here is an 4 player draw table

  A B C D
A   1 2 3
B 1   3 2
C 2 3   1
D 3 2 1
The letters represent the four teams, the numbers say which round each pair of teams is playing.

Test Data


Number of teams 
10 

Output

Match the format of the output in the example above.

Where there is more than one "draw table" you may return whichever you wish.

Constraints

You may assume the input is even. ##end task   I apologize to anybody with a non-html friendly e-mail client for spamming them with gibberish :)   Thanks in advance,  Adam.


Here is a quick and dirty solution. Not very Pythonesque, more a classical approach.
Take it as a challenge for Pythonistas to find a more *beautiful* one.
( http://www.lowerstandard.com/python/beautycontest.txt )

def roundrobin(n):
    # setup table
    global table
    table = [range(n)]
    for i in range(1,n):
        row = [i]
        while len(row)<n: row.append(0)
        table.append(row)
    # perform recursive brute search
    findround(1,2,n)
    # output in a dirty manner:
    for row in table: print row
 
def findround(row,col,dim):
    global table
    candidates = range(dim) # candidates for round to play the game
    # remove candidates already in the same row
    for i in range(col): candidates.remove(table[row][i])
    # remove candidates in rows already constructed
    for i in range(row):
        if table[i][col] in candidates: candidates.remove(table[i][col])
    for i in candidates:
        # try round nr. i
        table[row][col]=i
        table[col][row]=i
        if (row == dim-2) and (col == dim-1):
            # everything found
            return 1
        if col < dim - 1:
            if findround(row,col+1,dim):
                return 1
        elif row < dim - 2:
            if findround(row+1,row+2,dim):
                return 1
        # undo the try
        table[row][col]=0
        table[col][row]=0
    # no success
    return 0

# an now call for instance:

roundrobin(10) --------------C754C59664FDB96DF7AC6849-- From dyoo@hkn.eecs.berkeley.edu Mon Jun 18 00:57:40 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Sun, 17 Jun 2001 16:57:40 -0700 (PDT) Subject: [Tutor] Mac 1011 error after installation In-Reply-To: Message-ID: On Sun, 17 Jun 2001, Christopher Smith wrote: > I just tried to install the 2.1 Python on my Mac and have run into a > problem. After a succcessful installation, when I try to run the IDE it > quits with Mac error 1011 just after the splash screen goes away and the > editor window appears. Has anyone else encountered this or know what > might be wrong? Ouch! This sounds really specific to Macs; I don't have experience with them at all. If no one answers this soon, you might want to ask your question on the main comp.lang.python group. Another good place to ask is on the MacPython mailing list: http://www.python.org/mailman/listinfo/pythonmac-sig According to: http://www.peter.com.au/programming/mac-os-errors.html error 1011 matches up with the error: "Mixed mode failure". Dunno what that means, but perhaps it might be familiar to someone else. I hope someone can help you with this. Best of luck! From dyoo@hkn.eecs.berkeley.edu Mon Jun 18 00:58:10 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Sun, 17 Jun 2001 16:58:10 -0700 (PDT) Subject: [Tutor] Option of passing sequences are arguments In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz> Message-ID: On Sat, 16 Jun 2001, Phil Bertram wrote: > Is it possible to unpack a sequence to fill arguments. I have been > playing around with *args type aruments but can't seem to get it to > work. Yes, this is possible. > I would like to define a class so that it can be called as follows > > m = MyObject(arg1,arg2,arg3) > > or > > args=(arg1,arg2,arg3) > x=MyObject(args) It sounds like you're looking for the apply() function: ### >>> def h(a, b): ... return (a**2 + b**2)**.5 ... >>> args = (3, 4) >>> apply(h, args) 5.0 ### apply() will take in a function and a tuple. Once it has those things, it will call h, and use the tuple as a source for the arguments. If you want more examples, or if you have questions about it, feel free to ask us! Good luck! From deirdre@deirdre.net Mon Jun 18 02:07:52 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sun, 17 Jun 2001 18:07:52 -0700 Subject: [Tutor] Mac 1011 error after installation In-Reply-To: References: Message-ID: At 4:57 PM -0700 6/17/01, Danny Yoo wrote: >According to: > > http://www.peter.com.au/programming/mac-os-errors.html > >error 1011 matches up with the error: "Mixed mode failure". Dunno what >that means, but perhaps it might be familiar to someone else. > >I hope someone can help you with this. Best of luck! I know what it means, but it mystifies me. The Mixed Mode manager is a set of library routines to execute 68k code on a PowerPC. Why there would be any 68k code on the Python IDE is beyond me! -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From sburr@mac.com Mon Jun 18 06:44:20 2001 From: sburr@mac.com (Steven Burr) Date: Sun, 17 Jun 2001 22:44:20 -0700 Subject: [Tutor] Option of passing sequences are arguments In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz> Message-ID: <20010618054242.YSMA5596.femail17.sdc1.sfba.home.com@localhost> On Friday, June 15, 2001, at 03:53 PM, Phil Bertram wrote: > Is it possible to unpack a sequence to fill arguments. > I have been playing around with *args type aruments but can't seem to > get it > to work. > > Eg > > I would like to define a class so that it can be called as follows > > m = MyObject(arg1,arg2,arg3) > > or > > args=(arg1,arg2,arg3) > x=MyObject(args) I think this may be the kind of thing you're looking for (the __str__ method is just for testing purposes): import types class MyObject: def __init__(self, *args): if len(args) == 1 and type(args[0]) != types.StringType: try: test = args[0][0] except TypeError: self.args = args else: self.args = args[0] else: self.args = args def __str__(self): return ' '.join([str(x) for x in self.args]) a = MyObject("It's", 'only', 'a', 'flesh', 'wound!') print a args = ("I've", 'had', 'worse.') b = MyObject(args) print b c = MyObject("You're a loony!") print c d = MyObject(1) print d RESULT: It's only a flesh wound! I've had worse. You're a loony! 1 From dyoo@hkn.eecs.berkeley.edu Mon Jun 18 08:50:12 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Mon, 18 Jun 2001 00:50:12 -0700 (PDT) Subject: [Tutor] An IDLE introduction Message-ID: Hiya everyone, I'm starting to write up a small IDLE introduction for people who're just starting Python. As it is, it's really, really rough. I haven't finished writing in the comments, it still needs more image-captures, and all the writing needs to be rewritten for clarity. Still, I wanted to see if this sort of thing would be useful for people. Here's the web link (still disconnected from my main site): http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ Any comments would be greatly appreciated. Thanks! From glingl@aon.at Mon Jun 18 09:32:02 2001 From: glingl@aon.at (Gregor Lingl) Date: Mon, 18 Jun 2001 10:32:02 +0200 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> Message-ID: <3B2DBC82.AFC9B4D2@aon.at> Yesterday I posted a solution to the 'round-robin'-problem asked for by Adam Gordon. This solution (shown below) delivers solutions to the "test-data" of the problem-setting (i. e. for up to 10 teams) immediately. However, for a solution for 12 teams it needs 4 secs (on my machine), and for 14 teams 2400 secs. Sort of exponential runtime-behaviour. Consequently arises the question not only for a more beautiful program, but also for a more efficient algorithm (for there are certainly competitions with more than 14 teams). Seems interesting to me (although it probably is a so called 'well known' problem.) Well known to somebody of you? With curiosity Gregor Lingl > Here is a quick and dirty solution. Not very Pythonesque, more a > classical approach. > Take it as a challenge for Pythonistas to find a more *beautiful* one. > > ( http://www.lowerstandard.com/python/beautycontest.txt ) > > def roundrobin(n): > # setup table > global table > table = [range(n)] > for i in range(1,n): > row = [i] > while len(row) table.append(row) > # perform recursive brute search > findround(1,2,n) > # output in a dirty manner: > for row in table: print row > > def findround(row,col,dim): > global table > candidates = range(dim) # candidates for round to play the game > # remove candidates already in the same row > for i in range(col): candidates.remove(table[row][i]) > # remove candidates in rows already constructed > for i in range(row): > if table[i][col] in candidates: > candidates.remove(table[i][col]) > for i in candidates: > # try round nr. i > table[row][col]=i > table[col][row]=i > if (row == dim-2) and (col == dim-1): > # everything found > return 1 > if col < dim - 1: > if findround(row,col+1,dim): > return 1 > elif row < dim - 2: > if findround(row+1,row+2,dim): > return 1 > # undo the try > table[row][col]=0 > table[col][row]=0 > # no success > return 0 > > # an now call for instance: > > roundrobin(10) From wheelege@tsn.cc Mon Jun 18 11:37:51 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Mon, 18 Jun 2001 20:37:51 +1000 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at> Message-ID: <008b01c0f7e2$ba19daa0$0200a8c0@ACE> > > > Yesterday I posted a solution to the 'round-robin'-problem asked for > by Adam Gordon. > > This solution (shown below) delivers solutions to the "test-data" of the > > problem-setting (i. e. for up to 10 teams) immediately. > > However, for a solution for 12 teams it needs 4 secs (on my machine), > and for 14 teams 2400 secs. Sort of exponential runtime-behaviour. > > Consequently arises the question not only for a more beautiful program, > but also for a more efficient algorithm (for there are certainly > competitions with more than 14 teams). > > Seems interesting to me (although it probably is a so called 'well > known' > problem.) > > Well known to somebody of you? > Hmmm well with regards to the performance issue, I did notice quite a few 'in' keywords. And we all know what linear buggers they are :) This script could probably benefit exponentailly (ha ha) from using dictionaries as opposed to lists, then a simple has_key() call instead of 'in'. The beauty I can't really help you with - my python programs struggle to be elegant, let alone beautiful. Although I do know of several that I consider so...just not the ones I code :) It sure is an interesting problem. Perhaps a whole new unexpected approach would make it all alot easier? Brute force is usually just the tip of an iceberg. Glen. From wheelege@tsn.cc Mon Jun 18 11:55:41 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Mon, 18 Jun 2001 20:55:41 +1000 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at> <008b01c0f7e2$ba19daa0$0200a8c0@ACE> Message-ID: <009b01c0f7e5$37b5b2c0$0200a8c0@ACE> > Hmmm well with regards to the performance issue, I did notice quite a few > 'in' keywords > <..snip..> Argh, that's what sleep deprivation will do to you. There is only one 'in' keyword being used the way I meant...still, it would increase speed to use a hash...but prbably not to the extent your looking for. Whoops again, Glen. From aschmidt@nv.cc.va.us Mon Jun 18 12:10:57 2001 From: aschmidt@nv.cc.va.us (Schmidt, Allen J.) Date: Mon, 18 Jun 2001 07:10:57 -0400 Subject: [Tutor] An IDLE introduction Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0C9@novamail.nvcc.vccs.edu> Looks great so far! As a side note...I use a tool called ViewletBuilder2 from www.Qarbon.com to create step-by-step or interactive tutorials on various topics. Start a new VB2 project and it minimizes itself. Then just do whatever you normally do. Hit the PAUSE key anytime to capture a screenshot as often as you need. It tracks mouse movement, too. Then when finished, it jumps to the thumbnail view of all you captured. You can then go to each slide and add text balloons and callout bubbles to add your own information to the slide. Even records for voice annotation. This would certainly add clarity to for me on many Python topics. And completed Viewlets can be added for free to the library that anyone can view. Or serve them up for your own use or limited audience. The builder is Windows or *nix based but the Viewlets can be seen in any browser and live on almost any web server. Just thought I would offer a tip...Don't know enough about Python to be useful to the list yet. Allen -----Original Message----- From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu] Sent: Monday, June 18, 2001 3:50 AM To: tutor@python.org Subject: [Tutor] An IDLE introduction Hiya everyone, I'm starting to write up a small IDLE introduction for people who're just starting Python. As it is, it's really, really rough. I haven't finished writing in the comments, it still needs more image-captures, and all the writing needs to be rewritten for clarity. Still, I wanted to see if this sort of thing would be useful for people. Here's the web link (still disconnected from my main site): http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ Any comments would be greatly appreciated. Thanks! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From scarblac@pino.selwerd.nl Mon Jun 18 12:22:31 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 18 Jun 2001 13:22:31 +0200 Subject: [Tutor] A (not so) simple question? Round Robin In-Reply-To: <001601c0f6f1$9886dba0$05a616ca@computer1>; from adam0@tsn.cc on Sun, Jun 17, 2001 at 03:51:41PM +1000 References: <001601c0f6f1$9886dba0$05a616ca@computer1> Message-ID: <20010618132231.A10765@pino.selwerd.nl> On 0, Adam Gordon wrote: > Hey Guys! > > I am just starting to learn python (after hearing my friend praise it like a religion :) and thought I'd try out a few classic problems to help the learning process. > So, I went to Useless Python to check out the challenges, and then went to the High School comp section. I went to the 2000 open competition and looked for some fun problems. One which caught my eye was a Round Robin problem - didn't look too hard or too easy. > But, for the life of me I cannot do it! I've spent quite some time mulling it over but still an elegant solution eludes me...here is a copy of the problem as found on the website (here http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml). > > > ##start task > Task 5 - Round Robin > Description > n teams are to play each other in a competition. In each round each team plays exactly one other team. We wish to have as few rounds as possible. > > Write a program which, given an even number n, produces a "draw table" showing which team plays which team in each round. It is to take the minimum possible number of rounds. If more than one such draw table is possible your program may return whichever you wish. In chess tournaments, there are standard tables called "Berger tables". A program that shows tables like this is at http://chess.cern.ch/tournaments/robin.en.shtml Unfortunately, without source, so we'll have to reverse engineer the algorithm from the tables :-). Looking at the table for, say, 10 people, we see some patterns: - Player 1 plays white against player 10 in the first round, then white vs player 2, black vs 3, white vs 4, alternating until black vs 9 in round 9. - Player 2 starts against 9. Then in the second round he's already paired with 1. After that it continues 10, 3, 4, 5, 6, 7, 8. - Player 3 starts against 8. Then 9, the next in the list. He's already paired with 1 and 2 for the next two rounds. Then the list continues, playing 10, 4, 5, 6, 7. The pattern is slightly different for the upper half of the numbers, and my time is up. It shouldn't be too hard to find the algorithm and write a short function. -- Remco Gerlich From qhe@ydyn.com Mon Jun 18 14:47:24 2001 From: qhe@ydyn.com (Peter He) Date: Mon, 18 Jun 2001 08:47:24 -0500 Subject: [Tutor] Folder browser/chooser Message-ID: <5.1.0.14.0.20010618084711.00ae5370@mail.ydyn.com.criticalpath.net> Hi all, Is there a widget which works as a folder broswer/chooser? Just like tkFileDialog for file browser/chooser? Thanks! Peter From rol9999@attglobal.net Mon Jun 18 16:14:28 2001 From: rol9999@attglobal.net (Roland Schlenker) Date: Mon, 18 Jun 2001 10:14:28 -0500 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> Message-ID: <3B2E1AD4.B9D176BE@attglobal.net> > Adam Gordon wrote: > Description > > n teams are to play each other in a competition. In each round each > team plays exactly one other team. We wish to have as few rounds as > possible. > > Write a program which, given an even number n, produces a "draw table" > showing which team plays which team in each round. It is to take the > minimum possible number of rounds. If more than one such draw table is > possible your program may return whichever you wish. > > For example here is an 4 player draw table > > A B C D > A 1 2 3 > B 1 3 2 > C 2 3 1 > D 3 2 1 > Using the method suggested at: http://www.rain.org/~mkummel/stumpers/09feb01a.html I came up with: def outerZip(aList): assert 0 == len(aList) % 2 half = len(aList) / 2 listA, listB = aList[:half], aList[half:] listB.reverse() return zip(listA, listB) assert [(1, 6), (2, 5), (3, 4)] == outerZip([1, 2, 3, 4, 5, 6]) class RoundRobin: def __init__(self, teams): self.teams = teams self.rounds = [] def makeRounds(self): numberOfRounds = len(self.teams) - 1 pivotTeam, teams = self.teams[0], self.teams[1:] self.rounds = [] while 1: if numberOfRounds == 0: break playsPivotTeam, teams = teams[0], teams[1:] round = [(pivotTeam, playsPivotTeam)] + outerZip(teams) self.rounds.append(round) teams = teams + [playsPivotTeam] numberOfRounds -= 1 def playsWhoWhen(self, teamA, teamB): if teamA == teamB: return '' for round in self.rounds: for game in round: if teamA in game and teamB in game: return self.rounds.index(round) + 1 def roundsToString(self): result = [] result.append(" ") for team in self.teams: result.append(" " + team) result.append('\n') for team in self.teams: result.append(team) for opposingTeam in self.teams: result.append(" %1s" % self.playsWhoWhen(team, opposingTeam)) result.append('\n') return ''.join(result) aRound = RoundRobin(['A', 'B', 'C', 'D', 'E', 'F']) aRound.makeRounds() assert [[('A', 'B'), ('C', 'F'), ('D', 'E')], [('A', 'C'), ('D', 'B'), ('E', 'F')], [('A', 'D'), ('E', 'C'), ('F', 'B')], [('A', 'E'), ('F', 'D'), ('B', 'C')], [('A', 'F'), ('B', 'E'), ('C', 'D')]] == aRound.rounds assert 1 == aRound.playsWhoWhen('C', 'F') assert 5 == aRound.playsWhoWhen('A', 'F') assert " A B C D E F\n" +\ "A 1 2 3 4 5\n" +\ "B 1 4 2 5 3\n" +\ "C 2 4 5 3 1\n" +\ "D 3 2 5 1 4\n" +\ "E 4 5 3 1 2\n" +\ "F 5 3 1 4 2 \n" == aRound.roundsToString() Roland Schlenker From pobrien@orbtech.com Mon Jun 18 15:24:31 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Mon, 18 Jun 2001 09:24:31 -0500 Subject: [Tutor] An IDLE introduction In-Reply-To: Message-ID: Nice. I find having screenshots is a real comfort when you are starting out - one picture worth a thousand words and all that. Keep going. I think this is a very useful thing to have in the tutor arsenal. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Danny Yoo Sent: Monday, June 18, 2001 2:50 AM To: tutor@python.org Subject: [Tutor] An IDLE introduction Hiya everyone, I'm starting to write up a small IDLE introduction for people who're just starting Python. As it is, it's really, really rough. I haven't finished writing in the comments, it still needs more image-captures, and all the writing needs to be rewritten for clarity. Still, I wanted to see if this sort of thing would be useful for people. Here's the web link (still disconnected from my main site): http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ Any comments would be greatly appreciated. Thanks! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From chetumal23@excite.com Mon Jun 18 16:18:54 2001 From: chetumal23@excite.com (john smith smith) Date: Mon, 18 Jun 2001 08:18:54 -0700 (PDT) Subject: [Tutor] just saying thanks Message-ID: <15776461.992877534990.JavaMail.imail@cheeks.excite.com> i would just like to say you guys are the best, being a newbie to programming, i wasn't really getting it at first but you guys always offered great suggestions and encouragement. i'm far from the level you guys are but, i'm getting there. So once again THANKS! _______________________________________________________ Send a cool gift with your E-Card http://www.bluemountain.com/giftcenter/ From vlindberg@verio.net Mon Jun 18 16:37:35 2001 From: vlindberg@verio.net (VanL) Date: Mon, 18 Jun 2001 09:37:35 -0600 Subject: [Tutor] Python-to-to native compilation via java? Message-ID: <3B2E203F.1080600@verio.net> Hello, I was reading about the new gcc 3.0 release, and something that caught my eye: """ The GNU Compiler for the Java Programming Language What is GCJ? GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile: * Java source code directly to native machine code, * Java source code to Java bytecode (class files), * and Java bytecode to native machine code. Compiled applications are linked with the GCJ runtime, libgcj, which provides the core class libraries, a garbage collector, and a bytecode interpreter. libgcj can dynamically load and interpret class files, resulting in mixed compiled/interpreted applications. """ Would code get any significant speedup by going jython -> .class files -> native? Thanks, Van From dyoo@hkn.eecs.berkeley.edu Mon Jun 18 17:50:21 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Mon, 18 Jun 2001 09:50:21 -0700 (PDT) Subject: [Tutor] Python-to-to native compilation via java? In-Reply-To: <3B2E203F.1080600@verio.net> Message-ID: On Mon, 18 Jun 2001, VanL wrote: > I was reading about the new gcc 3.0 release, and something that caught > my eye: Did the new gcc come out today? Very cool! (For those who might be unfamiliar with "gcc": gcc is a collection of compilers for many programming languages, including C and Java. Python is built on top of C, and it's really neat to see how our favorite language is built on top of this "simpler" environment.) > Compiled applications are linked with the GCJ runtime, libgcj, which > provides the core class libraries, a garbage collector, and a bytecode > interpreter. libgcj can dynamically load and interpret class files, > resulting in mixed compiled/interpreted applications. """ > > Would code get any significant speedup by going jython -> .class > files -> native? Hmmm... I don't know! The Jython people might know; can you ask them about it? I'm also interested in hearing if Jython compiles well in gcj. From jrfrog01@msn.com Mon Jun 18 17:52:34 2001 From: jrfrog01@msn.com (jay aliason) Date: Mon, 18 Jun 2001 12:52:34 -0400 Subject: [Tutor] help for a beginner Message-ID: ------=_NextPart_001_0004_01C0F7F5.8BA0E700 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am currently trying to learn the language that is Python. The problem = is the last language I ever programmed was BASIC. So I need to know what= tools I need to get started I.E. -Start up platform -which version to use -how to get the screen to let me type the language I am using a compaq 1700T laptop. It is a pentium III and runs at 800mhz= . With windows Me. Any help would be useful. Thanks for your time and patience, The Frog ------=_NextPart_001_0004_01C0F7F5.8BA0E700 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I am currently= trying to learn the language that is Python.  The problem is the la= st language I ever programmed was BASIC.  So I need to know what too= ls I need to get started I.E.  -Start up platform

-which vers= ion to use
-how to get the screen to let me type the language<= /DIV>
 
 
I am using a compaq 1700T = laptop.  It is a pentium III and runs at 800mhz.   With wi= ndows Me.
Any help would be useful.  Thanks for your time= and patience,
        = ;            =             &= nbsp;         The Frog
------=_NextPart_001_0004_01C0F7F5.8BA0E700-- From nailed@videotron.ca Mon Jun 18 18:25:44 2001 From: nailed@videotron.ca (Alain Toussaint) Date: Mon, 18 Jun 2001 13:25:44 -0400 Subject: [Tutor] Python-to-to native compilation via java? In-Reply-To: References: Message-ID: <01061813254400.02485@alain> Hello Everyone, > Did the new gcc come out today? Very cool! yes it did,have a look at http://gcc.gnu.org/ i will probably download it in the next few days but i will be able to throughly test it after Samba 2.2.1 is out (at that time,i will rebuild my box). Alain Toussaint From kalle@gnupung.net Mon Jun 18 18:56:38 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Mon, 18 Jun 2001 19:56:38 +0200 Subject: [Tutor] help for a beginner In-Reply-To: ; from jrfrog01@msn.com on Mon, Jun 18, 2001 at 12:52:34PM -0400 References: Message-ID: <20010618195638.A12799@gandalf> Sez jay aliason: > I am currently trying to learn the language that is Python. The problem > is the last language I ever programmed was BASIC. So I need to know what > tools I need to get started I.E. -Start up platform > > -which version to use Generally, the latest official version is a good bet. Currently, this is 2.1, and it can be downloaded from http://www.python.org/2.1/ I've heard people say that ActiveState Python is good for Windows users. I don't know, but more info can be found on http://aspn.activestate.com/ASPN/Downloads/ActivePython/ > -how to get the screen to let me type the language You can use a editor/environment that comes with Python. This can be IDLE, which is included in the stadard Python distribution, or Pythonwin, which is included with ActiveState Python. In any of these tools, you have interactive interpreter windows for testing. You can also edit python module files that you can save, distribute and run. These can be edited in any text editor, but IDLE and Pythonwin have syntax highlighting and indentation support that make writing Python easier. A good tutorial is http://www.crosswinds.net/~agauld/ Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From dyoo@hkn.eecs.berkeley.edu Mon Jun 18 18:59:41 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Mon, 18 Jun 2001 10:59:41 -0700 (PDT) Subject: [Tutor] help for a beginner In-Reply-To: Message-ID: On Mon, 18 Jun 2001, jay aliason wrote: > I am currently trying to learn the language that is Python. The > problem is the last language I ever programmed was BASIC. So I need That's not too much of a problem. In fact, it's great that you have some experience in BASIC, since the idea of an "interpreter" might seem familiar to you. Python has the "print" command too, so there's some similarities you can take advantage of... *grin* > to know what tools I need to get started I.E. -Start up platform > -which version to use -how to get the screen to let me type the > language Python 2.1 is the latest version, and that's probably what you'll want to get. Since you're running Win ME, you can just download the .exe file for Python: in an ideal world, it works uniformly on Windows 95/98/2000/ME/NT. > I am using a compaq 1700T laptop. It is a pentium III and runs at > 800mhz. With windows Me. Any help would be useful. Thanks for your > time and patience, This sounds good. You'll want to download the Python interpreter, and it can be found here: http://python.org/2.1/#locations All you'll probably need to download is the is the Python-2.1.exe file. It's a 6 MB download, which isn't too bad. It comes with all the tools you'll need to get started: o Python itself --- the "interpreter" that forms the heart of the system. o IDLE --- the Integrated Development Environment that's both a text editor and a nice way to play around with Python. (At the moment, I'm trying to write a small "First Day" guide on IDLE. Give me another day or so, and I'll be able to post it up.) You don't need to buy a book to learn Python (although there are a lot of good ones out there). You can browse through a few introductions and tutorials here: http://python.org/doc/Intros.html Alan Gauld's "Learning to Program": http://www.crosswinds.net/~agauld/ as well as Josh Cogliati's "A Non-Programmer's Tutorial for Python": http://www.honors.montana.edu/~jjc/easytut/easytut/ are both good tutorials, and start from the basics. Finally, you have us: Ask us any questions you have about Python, and we'll be happy to talk about them. Best of wishes! From nluken@earthlink.net Mon Jun 18 19:45:52 2001 From: nluken@earthlink.net (Noah Luken) Date: Mon, 18 Jun 2001 14:45:52 -0400 Subject: [Tutor] a question about making standalone .exes from python Message-ID: <05ad01c0f826$e785b880$4d6d1a26@noah2lxehj3pbz> This is a multi-part message in MIME format. ------=_NextPart_000_05AA_01C0F805.5F20E490 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi everyone,=20 (Let me preface this question -- I am a student of architecture = interested in using python for basic graphic design, algorithms, etc. = I have, in the process, been forced to learn some Tkinter, some (quite a = bit) of OpenGL, as well as the usual complement of useful python = modules. (PIL, Numeric, pyglut, etc.). I'm a newbie at ALL of them = (sigh).) I'm trying to make a standalone .exe of a python script which invokes = and draws in an openGL window. The imports are thus: from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * import whrandom import time I poked around on the internet and tried Installer by Gordon MacMillan, = since it seemed most up to date. After installing and running = SetupTk.py once, I tried his standalone.py on my script = (interaction02.py) and got this result: > c:\python21\python.exe c:\python21\installer\Builder.py interaction W: exec statment detected at line 281 of imputil W: No module named dos W: No module named mac W: No module named nt.stat W: No module named os2 W: No module named posix W: Cannot determine your Windows or System directories W: Please add them to your PATH if .dlls are not found W: exec statment detected at line 65 of os W: exec statment detected at line 138 of os W: eval hack detected at line 405 of os W: No module named ce W: No module named strop.lowercase W: No module named strop.maketrans W: No module named strop.uppercase W: No module named strop.whitespace W: No module named win32api W: No module named pwd W: No module named riscos W: No module named riscosenviron W: No module named riscospath W: No module named MACFS W: No module named macfs W: No module named errno.EINVAL W: eval hack detected at line 634 of pickle W: __import__ hack detected at line 786 of pickle W: No module named OpenGL.dynload._opengl W: No module named OpenGL.dynload._opengl_num W: No module named OpenGL.dynload.openglutil W: No module named OpenGL.dynload.openglutil_num W: No module named OpenGL.dynload.wgl W: No module named OpenGL.GL.CarefulFunction W: No module named OpenGL.GL.Error W: No module named OpenGL.dynload._glu W: No module named OpenGL.dynload._glu_num W: No module named OpenGL.dynload._glut Needless to say, this program didn't work on a machine with opengl card, = drivers, etc. (problem with .dynload modules) I'm curious if there's a = way to get standalone .exe programs to work with python, and I'm also = wondering if I shouldn't just bite the bullet and program this in C or = C++ (which would involve learning one of the bad old languages I thought = I could avoid). Is there a way to go from python to c to an .exe? Is = python the right language for this or am I barking up the wrong tree = here? thanks in advance for any help you can offer. -noah luken nluken@mit.edu=20 =20 ------=_NextPart_000_05AA_01C0F805.5F20E490 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi everyone,
 
(Let me preface this question -- I am a = student of=20 architecture interested in using python for basic graphic design, = algorithms,=20 etc.   I have, in the process, been forced to learn some = Tkinter,=20 some (quite a bit) of OpenGL, as well as the usual complement of = useful=20 python modules. (PIL, Numeric, pyglut, etc.).  I'm a newbie at ALL = of them=20 (sigh).)
 
I'm trying to make a standalone .exe of = a=20 python script which invokes and draws in an=20 openGL window.  The imports are thus:
 
from OpenGL.GL import *
from = OpenGL.GLUT import=20 *
from OpenGL.GLU import *
import whrandom
import = time
 
I poked around on the internet and = tried Installer=20 by Gordon MacMillan, since it seemed most up to date.  After = installing and=20 running SetupTk.py once, I tried his standalone.py on my script=20 (interaction02.py) and got this result:
 
 
> c:\python21\python.exe=20 c:\python21\installer\Builder.py  interaction
W: exec statment = detected=20 at line 281 of imputil
W: No module named dos
W: No module named = mac
W:=20 No module named nt.stat
W: No module named os2
W: No module named=20 posix
W: Cannot determine your Windows or System directories
W: = Please add=20 them to your PATH if .dlls are not found
W: exec statment detected at = line 65=20 of os
W: exec statment detected at line 138 of os
W: eval hack = detected at=20 line 405 of os
W: No module named ce
W: No module named=20 strop.lowercase
W: No module named strop.maketrans
W: No module = named=20 strop.uppercase
W: No module named strop.whitespace
W: No module = named=20 win32api
W: No module named pwd
W: No module named riscos
W: No = module=20 named riscosenviron
W: No module named riscospath
W: No module = named=20 MACFS
W: No module named macfs
W: No module named = errno.EINVAL
W: eval=20 hack detected at line 634 of pickle
W: __import__ hack detected at = line 786=20 of pickle
W: No module named OpenGL.dynload._opengl
W: No module = named=20 OpenGL.dynload._opengl_num
W: No module named = OpenGL.dynload.openglutil
W:=20 No module named OpenGL.dynload.openglutil_num
W: No module named=20 OpenGL.dynload.wgl
W: No module named OpenGL.GL.CarefulFunction
W: = No=20 module named OpenGL.GL.Error
W: No module named = OpenGL.dynload._glu
W: No=20 module named OpenGL.dynload._glu_num
W: No module named=20 OpenGL.dynload._glut
Needless to say, this program didn't = work on a=20 machine with opengl card, drivers, etc. (problem with .dynload modules) = I'm=20 curious if there's a way to get standalone .exe programs to = work with=20 python, and I'm also wondering if I shouldn't just bite the bullet and = program=20 this in C or C++ (which would involve learning one of the bad old = languages I=20 thought I could avoid).  Is there a way to go from python = to=20 c to an .exe?  Is python the right language for this or am I = barking=20 up the wrong tree here?
 
thanks in advance for any help you can=20 offer.
 
-noah luken
 
 
 
 
------=_NextPart_000_05AA_01C0F805.5F20E490-- From wesc@deirdre.org Mon Jun 18 20:02:53 2001 From: wesc@deirdre.org (Wesley Chun) Date: Mon, 18 Jun 2001 12:02:53 -0700 (PDT) Subject: [Tutor] Taking Mark Lutz's training course In-Reply-To: Message-ID: On Thu, 14 Jun 2001, Daniel Yoo wrote: > On Thu, 14 Jun 2001 kromag@nsacom.net wrote: > > Daniel Yoo said: > > > > And now for something completely different: > > > > Have you taken, or talked to anyone who has taken Mark Lutz' Python > > classes? It sounds like a good three days, but the money gods have > > frowned upon me this year. I _really_ get a lot of mileage out of > > "Learning Python", so I am inclined toward spending my dough with him. > > No, I haven't taken one of his classes. Has anyone here taken one? What > are they like? I don't know anyone who has either, but he *is* rather busy doing it! In fact, he told me a few days ago that he would have to start passing business to *me* if July has the same torrid training pace as June! :-) > > I have yet to find a college in the midwest that even teaches Python. > > *sigh* > > I actually tried to do a small "Introduction to Python" session in > Berkeley once. What a disaster! The problem was that the language was so > obvious, so simple, that I didn't need to say anything... *grin* I teach the Python course for the University of California, Santa Cruz extension system -- rather than teaching for students on-campus, these are once-a-week evening courses for working professionals. I believe UC Berkeley is offering a similar course. Teaching the actual language, as Daniel pointed out, is rather straightforward. The rest of the time, I'm overworking them with exercises, then doing more advanced topics (i.e., network- ing, regular expressions, GUIs and Tkinter, web programming, etc.) towards the end of the 8-week course. By the time they're done, not only do they know Python, but are good programmers as well! ;-) -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc@baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From scastell@sas.upenn.edu Mon Jun 18 22:41:27 2001 From: scastell@sas.upenn.edu (Steven M. Castellotti) Date: Mon, 18 Jun 2001 16:41:27 -0500 Subject: [Tutor] Re: [Jython-users] Python to native compilation via java? References: <3B2E6291.8000907@lindbergs.org> Message-ID: <3B2E7587.AA221ECC@sas.upenn.edu> A very good question! However, don't forget that if the software you're writing is GPL'd, there might be a restriction on compiling it together with jython, due to a conflict between the GPL and jython's license. VanL wrote: > > Hello, > > (Cross-posted by request from the python-tutor mailing list) > > I was reading about the new gcc 3.0 release, and something that caught > my eye: > > """ > The GNU Compiler for the Java Programming Language > What is GCJ? > > GCJ is a portable, optimizing, ahead-of-time compiler for the Java > Programming Language. It can compile: > > * Java source code directly to native machine code, > * Java source code to Java bytecode (class files), > * and Java bytecode to native machine code. > > Compiled applications are linked with the GCJ runtime, libgcj, which > provides the core class libraries, a garbage collector, and a bytecode > interpreter. libgcj can dynamically load and interpret class files, > resulting in mixed compiled/interpreted applications. > """ > > Would code get any significant speedup by going jython -> .class files > -> native? Is it possible? And does jython compile under gcj? > > Thanks, > > Van -- Steve Castellotti Systems Programmer School of Arts and Sciences, University of Pennsylvania From GBunting864@Worldsavings.com Mon Jun 18 22:14:06 2001 From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x)) Date: Mon, 18 Jun 2001 16:14:06 -0500 Subject: [Tutor] Taking Mark Lutz's training course Message-ID: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com> Where could I find information about the UCSC extension class? I have looked on their web site but I could not find anything on python. Thanks Glen -----Original Message----- From: Wesley Chun [mailto:wesc@deirdre.org] Sent: Monday, June 18, 2001 12:03 PM To: Daniel Yoo Cc: kromag@nsacom.net; tutor@python.org Subject: Re: [Tutor] Taking Mark Lutz's training course On Thu, 14 Jun 2001, Daniel Yoo wrote: > On Thu, 14 Jun 2001 kromag@nsacom.net wrote: > > Daniel Yoo said: > > > > And now for something completely different: > > > > Have you taken, or talked to anyone who has taken Mark Lutz' Python > > classes? It sounds like a good three days, but the money gods have > > frowned upon me this year. I _really_ get a lot of mileage out of > > "Learning Python", so I am inclined toward spending my dough with him. > > No, I haven't taken one of his classes. Has anyone here taken one? What > are they like? I don't know anyone who has either, but he *is* rather busy doing it! In fact, he told me a few days ago that he would have to start passing business to *me* if July has the same torrid training pace as June! :-) > > I have yet to find a college in the midwest that even teaches Python. > > *sigh* > > I actually tried to do a small "Introduction to Python" session in > Berkeley once. What a disaster! The problem was that the language was so > obvious, so simple, that I didn't need to say anything... *grin* I teach the Python course for the University of California, Santa Cruz extension system -- rather than teaching for students on-campus, these are once-a-week evening courses for working professionals. I believe UC Berkeley is offering a similar course. Teaching the actual language, as Daniel pointed out, is rather straightforward. The rest of the time, I'm overworking them with exercises, then doing more advanced topics (i.e., network- ing, regular expressions, GUIs and Tkinter, web programming, etc.) towards the end of the 8-week course. By the time they're done, not only do they know Python, but are good programmers as well! ;-) -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc@baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ***************************************************************************** If you are not the intended recipient of this e-mail, please notify the sender immediately. The contents of this e-mail do not amend any existing disclosures or agreements unless expressly stated. ***************************************************************************** From glingl@aon.at Mon Jun 18 22:21:14 2001 From: glingl@aon.at (Gregor Lingl) Date: Mon, 18 Jun 2001 23:21:14 +0200 Subject: [Tutor] A (not so) simple question? Round Robin References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at> <008b01c0f7e2$ba19daa0$0200a8c0@ACE> <009b01c0f7e5$37b5b2c0$0200a8c0@ACE> Message-ID: <3B2E70CA.64EEE1E7@aon.at> Glen Wheeler schrieb: > > Hmmm well with regards to the performance issue, I did notice quite a > few > > 'in' keywords > > <..snip..> > > Argh, that's what sleep deprivation will do to you. There is only one > 'in' keyword being used the way I meant...still, it would increase speed to > use a hash...but prbably not to the extent your looking for. > Whoops again, > > Glen. So I had to search for a faster method and the internet once more proved its richness: google ( round robin tournament program ) led me to http://www.rain.org/~mkummel/stumpers/09feb01a.html where a description of an ingenious geometrically motivated algorithm is given. Here is the corresponding Python-program: def roundrobin(n): """implements a geometrically motivated algorithm to construct a table for a round-robin-tournament. The algorithm is called 'polygon method' and described at http://www.rain.org/~mkummel/stumpers/09feb01a.html """ # construct table filled with zeros row = [] while len(row) References: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com> Message-ID: At 4:14 PM -0500 6/18/01, Bunting, Glen, IG (x) wrote: >Where could I find information about the UCSC extension class? I have >looked on their web site but I could not find anything on python. Wes hasn't been teaching at UCSC for the last semester. If you're desperate (gah, I can't spell today!) for something in the near future, Berkeley is offering one in its extension program for the first time in Summer. Otherwise, I'd wait for Wes' next. :) -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "Cannot run out of time.... Is infinite time. You... are finite.... Zathrus... is finite. This... is wrong tool!" -- Zathrus From danny.ayers@btinternet.com Mon Jun 18 23:45:06 2001 From: danny.ayers@btinternet.com (Danny Ayers) Date: Mon, 18 Jun 2001 23:45:06 +0100 Subject: [Tutor] RE: [Jython-users] Python to native compilation via java? In-Reply-To: <3B2E6291.8000907@lindbergs.org> Message-ID: I've just been looking at some of the intermediate Java code generated by jythonc on its way to a .class. I may be wrong, but it looks to me like the class is will effectively wrap up the python source, which will be interpreted by the interpreter embedded in jpython. To compile this up to native code, unless the compiler is *really* smart it would carry over all the inefficiencies of the interpretation process, and so I would guess that the performance improvements overall are likely to be minimal or non-existent, compared to running the Python source on a native interpreter. I guess. BTW, I've just been trying to find a good way of porting Python source over to Java, and made a small step forward using the Object Domain UML tool (time limited demo) - it can generate the Java classes and method shells (from UML generated from Python), which with a bit of search & replace (get rid of 'self'!) should save a fair bit of hand coding. --- Danny Ayers http://www.isacat.net >-----Original Message----- >From: jython-users-admin@lists.sourceforge.net >[mailto:jython-users-admin@lists.sourceforge.net]On Behalf Of VanL >Sent: 18 June 2001 21:21 >To: jython-users@lists.sourceforge.net >Subject: [Jython-users] Python to native compilation via java? > > >Hello, > >(Cross-posted by request from the python-tutor mailing list) > >I was reading about the new gcc 3.0 release, and something that caught >my eye: > >""" >The GNU Compiler for the Java Programming Language >What is GCJ? > >GCJ is a portable, optimizing, ahead-of-time compiler for the Java >Programming Language. It can compile: > > * Java source code directly to native machine code, > * Java source code to Java bytecode (class files), > * and Java bytecode to native machine code. > >Compiled applications are linked with the GCJ runtime, libgcj, which >provides the core class libraries, a garbage collector, and a bytecode >interpreter. libgcj can dynamically load and interpret class files, >resulting in mixed compiled/interpreted applications. >""" > >Would code get any significant speedup by going jython -> .class files >-> native? Is it possible? And does jython compile under gcj? > >Thanks, > >Van > > > >_______________________________________________ >Jython-users mailing list >Jython-users@lists.sourceforge.net >http://lists.sourceforge.net/lists/listinfo/jython-users From dyoo@hkn.eecs.berkeley.edu Tue Jun 19 00:36:25 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Mon, 18 Jun 2001 16:36:25 -0700 (PDT) Subject: [Tutor] Re: [Python-Help] folder browser/chooser In-Reply-To: <5.1.0.14.0.20010618141443.00af6eb8@mail.ydyn.com.criticalpath.net> Message-ID: On Mon, 18 Jun 2001, Peter He wrote: > Is there a widget which works as a folder browser/chooser? Just like > tkFileDialog for file browser/chooser. Hmmm... I'm not quite sure about this one. Wait, wait, I know I've seen this question before though. Let's see... Ah! Ok, you'll want to take a look at Rick Pasotto's answer: http://mail.python.org/pipermail/tutor/2001-May/005270.html There is a FileDialog widget that's just not documented well, but it is there. Thanks Rick! From wesc@deirdre.org Tue Jun 19 00:36:52 2001 From: wesc@deirdre.org (Wesley Chun) Date: Mon, 18 Jun 2001 16:36:52 -0700 (PDT) Subject: [Tutor] Taking Mark Lutz's training course In-Reply-To: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com> Message-ID: glen, i apologize for neglecting to mention that due to personal reasons, i have not been able to teach the Python course for UCSC during this year. the next class is tentatively set for Winter quarter 2002. i am available for corporate training however if you company wants to train a bunch of people, i'll come out there. Mark Lutz does mething similar although most of his courses are taught near where *he* lives. hope this helps! -wesley On Mon, 18 Jun 2001, Bunting, Glen, IG (x) wrote: > Where could I find information about the UCSC extension class? I have > looked on their web site but I could not find anything on python. > > Thanks > > Glen > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > "Core Python Programming", Prentice Hall PTR, December 2000 > http://starship.python.net/crew/wesc/cpp/ > > wesley.j.chun :: wesc@baypiggies.org > cyberweb.consulting :: silicon.valley, ca > http://www.roadkill.com/~wesc/cyberweb/ From michael@exasource.com Tue Jun 19 03:14:37 2001 From: michael@exasource.com (Michael) Date: Mon, 18 Jun 2001 20:14:37 -0600 Subject: [Tutor] Python and web scripting Message-ID: <01061820143700.02862@orion.andromeda> Hi, I'm new to Python and new to programming. I've done html and a few javascripts and was wanting to learn a real programming language. After reading up on all the possibilities, I decided to learn Python as my first. My question is, how is Python used in a web development application. Can it be used in the same manner, but instead of PHP? Are there any tutorials / books that cover this aspect? Thanks, Michael PS I liked the IDLE tutorial, I've already learned some things from that even though it is not finished. From dyoo@hkn.eecs.berkeley.edu Tue Jun 19 07:19:53 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Mon, 18 Jun 2001 23:19:53 -0700 (PDT) Subject: [Tutor] a question about making standalone .exes from python In-Reply-To: <05ad01c0f826$e785b880$4d6d1a26@noah2lxehj3pbz> Message-ID: On Mon, 18 Jun 2001, Noah Luken wrote: > I poked around on the internet and tried Installer by Gordon > MacMillan, since it seemed most up to date. After installing and > running SetupTk.py once, I tried his standalone.py on my script > (interaction02.py) and got this result: Have you tried py2exe? I believe it too is being actively developed; from what I've heard, it's very good and easier to work with than McMillian's Installer. You can find out about py2exe here: http://starship.python.net/crew/theller/py2exe/ Good luck! From jstanley@start.com.au Tue Jun 19 10:28:22 2001 From: jstanley@start.com.au (Jordan Stanley) Date: Tue, 19 Jun 2001 19:28:22 +1000 Subject: [Tutor] Re: An IDLE Introduction Message-ID: i thinks its great so far just a suggestion, how about introducing varibales eg a=3 s=3*a etc i'll certainly be coming back to see how the site is going Jordan RE: An IDLE introduction (Patrick K. O'Brien) > >-----Original Message----- >From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of >Danny Yoo >Sent: Monday, June 18, 2001 2:50 AM >To: tutor@python.org >Subject: [Tutor] An IDLE introduction > >Hiya everyone, > >I'm starting to write up a small IDLE introduction for people who're just >starting Python. As it is, it's really, really rough. I haven't finished >writing in the comments, it still needs more image-captures, and all the >writing needs to be rewritten for clarity. > >Still, I wanted to see if this sort of thing would be useful for people. >Here's the web link (still disconnected from my main site): > > http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ > >Any comments would be greatly appreciated. Thanks! __________________________________________________________________ Get your free Australian email account at http://www.start.com.au From fasal.waseem@cis.co.uk Tue Jun 19 12:10:58 2001 From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk) Date: Tue, 19 Jun 2001 11:10:58 +0000 Subject: [Tutor] Attribute Error Message-ID: Hi All is abspath an attribute of 1.5, if not is there some equivalent of it. Faz Distributed system support Analyst CIS Miller Street Manchester M60 0AL 0161 837 4487 (office) www.cis.co.uk (our web page) ************************************************************************* This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author. The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes: Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name Registered offices: Miller Street, Manchester M60 0AL Telephone 0161-832-8686 Internet http://www.cis.co.uk E-mail cis@cis.co.uk CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank. CIS & the CIS logo (R) Co-operative Insurance Society Limited ******************************************************************************** From scarblac@pino.selwerd.nl Tue Jun 19 11:19:14 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 19 Jun 2001 12:19:14 +0200 Subject: [Tutor] Attribute Error In-Reply-To: ; from fasal.waseem@cis.co.uk on Tue, Jun 19, 2001 at 11:10:58AM +0000 References: Message-ID: <20010619121914.A12613@pino.selwerd.nl> On 0, fasal.waseem@cis.co.uk wrote: > Hi All > > is abspath an attribute of 1.5, if not is there some equivalent of it. I think you're talking about os.path.abspath(). It's not in 1.5, but was new in 1.5.2; the current documentation says: (http://www.python.org/doc/current/lib/module-os.path.html) abspath(path) Return a normalized absolutized version of the pathname 'path'. On most platforms, this is equivalent to os.path.normpath(os.path.join(os.getcwd(), path)) New in version 1.5.2. That line (basically adds the current directory and the path together and normalizes it) should work. -- Remco Gerlich From fasal.waseem@cis.co.uk Tue Jun 19 13:10:04 2001 From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk) Date: Tue, 19 Jun 2001 12:10:04 +0000 Subject: [Tutor] Attribute Error Message-ID: Hi there Yes I am trying to use os.path.abspath and I am getting error as shown below; progspec=os.path.abspath(sys.argv[0]) AttributeError: abspath how do use sys.argv and normpath together. regards Faz Distributed system support Analyst CIS Miller Street Manchester M60 0AL 0161 837 4487 (office) www.cis.co.uk (our web page) Remco Gerlich cc: Sent by: Subject: Re: [Tutor] Attribute Error tutor-admin@pyth on.org 19/06/01 10:19 On 0, fasal.waseem@cis.co.uk wrote: > Hi All > > is abspath an attribute of 1.5, if not is there some equivalent of it. I think you're talking about os.path.abspath(). It's not in 1.5, but was new in 1.5.2; the current documentation says: (http://www.python.org/doc/current/lib/module-os.path.html) abspath(path) Return a normalized absolutized version of the pathname 'path'. On most platforms, this is equivalent to os.path.normpath(os.path.join(os.getcwd(), path)) New in version 1.5.2. That line (basically adds the current directory and the path together and normalizes it) should work. -- Remco Gerlich _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ************************************************************************* This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author. The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes: Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name Registered offices: Miller Street, Manchester M60 0AL Telephone 0161-832-8686 Internet http://www.cis.co.uk E-mail cis@cis.co.uk CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank. CIS & the CIS logo (R) Co-operative Insurance Society Limited ******************************************************************************** From arcege@speakeasy.net Tue Jun 19 12:00:02 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Tue, 19 Jun 2001 07:00:02 -0400 (EDT) Subject: [Tutor] Attribute Error In-Reply-To: <20010619121914.A12613@pino.selwerd.nl> from "Remco Gerlich" at Jun 19, 2001 12:19:14 PM Message-ID: <200106191100.f5JB02i01811@dsl092-074-184.bos1.dsl.speakeasy.net> Remco Gerlich wrote > > On 0, fasal.waseem@cis.co.uk wrote: > > is abspath an attribute of 1.5, if not is there some equivalent of it. > > I think you're talking about os.path.abspath(). I took this a completely different way. I was thinking of 1.5 as a float, not a release number. For a floating point number, you are probably looking for the abs() function. It is a builtin, so you can just use it directly: $ python -c 'print abs(-1.5), abs(1.5)' 1.5 1.5 But with this illness, I could have easily gotten mistaken. :) -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From scarblac@pino.selwerd.nl Tue Jun 19 12:14:13 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 19 Jun 2001 13:14:13 +0200 Subject: [Tutor] Attribute Error In-Reply-To: ; from fasal.waseem@cis.co.uk on Tue, Jun 19, 2001 at 12:10:04PM +0000 References: Message-ID: <20010619131413.A12716@pino.selwerd.nl> On 0, fasal.waseem@cis.co.uk wrote: > Yes I am trying to use os.path.abspath and I am getting error as shown > below; > > progspec=os.path.abspath(sys.argv[0]) > AttributeError: abspath > > how do use sys.argv and normpath together. Let's see how I wrote that again, from the library reference documents: > abspath(path) > Return a normalized absolutized version of the pathname 'path'. On most > platforms, this is equivalent to > os.path.normpath(os.path.join(os.getcwd(), path)) > New in version 1.5.2. That means that your line should be written: progspec = os.path.normpath(os.path.join(os.getcwd(), sys.argv[0])) to work on 1.5. (in your case 'path', the argument to abspath(), is 'sys.argv[0]') -- Remco Gerlich From rhess@bic.ch Tue Jun 19 15:00:24 2001 From: rhess@bic.ch (Flynt) Date: Tue, 19 Jun 2001 16:00:24 +0200 Subject: [Tutor] Python and web scripting References: <01061820143700.02862@orion.andromeda> Message-ID: <3B2F5AF8.CF125658@bic.ch> Michael wrote: > > Hi, > > I'm new to Python and new to programming. I've done html and a few > javascripts and was wanting to learn a real programming language. After > reading up on all the possibilities, I decided to learn Python as my first. > > My question is, how is Python used in a web development application. Can it > be used in the same manner, but instead of PHP? Are there any tutorials / > books that cover this aspect? > > Thanks, > > Michael > > PS I liked the IDLE tutorial, I've already learned some things from that even > though it is not finished. > Hi Michael There is a nice package, HTMLgen (http://starship.python.net/crew/friedrich/HTMLgen/html/main.html), which helps you a lot writing HTML. There is an web application server based entirely on Python, called Zope (the link is http://www.zope.org/). This is a full featured web application server framework, for which also a lot of Add-On modules are already developed to handle special functionalities. You have to spend some time studying the docs, to see what it is capable of, but I think it is well worth a try. Because of the use of python, I think you are moving on much better founded ground than by using PHP, which might be quicker in the first place to implement but gives not as much back, when you are going to more involved problems. And, in IMO, PHP is *web only*, whereas with Python you can work in just all areas. A comprehensive introduction to Zope will come out right now at New Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier (search for "Zope" on amazon). You can have a look at the last draft of the book at http://www.zope.org/Members/michel/ZB/ HTH --- Flynt From bill-bell@bill-bell.hamilton.on.ca Tue Jun 19 16:42:04 2001 From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 19 Jun 2001 11:42:04 -0400 Subject: [Tutor] Elementary questions In-Reply-To: Message-ID: <3B2F3A8C.16726.34CAA9D@localhost> Would it be possible for someone to point me toward advice about the following points? 1. When I launch PythonWin its window occupies only part of my screen. How may I configure it to use the entire screen? Similarly, is it possible to configure PythonWin so that child windows (for code, for instance) occupy the entire client window? 2. When I launch a .py script from Windows Explorer the resulting DOS box closes before I'm able to read about exceptions. How may I change this behaviour of the system? Thanks in advance. Bill From pobrien@orbtech.com Tue Jun 19 16:55:44 2001 From: pobrien@orbtech.com (Patrick K. O'Brien) Date: Tue, 19 Jun 2001 10:55:44 -0500 Subject: [Tutor] Elementary questions In-Reply-To: <3B2F3A8C.16726.34CAA9D@localhost> Message-ID: 1. Right click on the link or menu choice for PythonWin. You will see an option labeled "Run." Set it to Maximized and PythonWin will launch in full screen mode. If you maximize a child window in PythonWin, all existing and subsequent children will open maximized. Restore one and you restore all, etc. Like a toggle. 2. Don't run the file by double-clicking on it. You could start a dos window and then do "python thefile.py". Or run the .py file from IDLE or PythonWin. Sorry about the brevity, but hope that helps. --- Patrick K. O'Brien Orbtech "I am, therefore I think." -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Bill Bell Sent: Tuesday, June 19, 2001 10:42 AM To: tutor@python.org Subject: [Tutor] Elementary questions Would it be possible for someone to point me toward advice about the following points? 1. When I launch PythonWin its window occupies only part of my screen. How may I configure it to use the entire screen? Similarly, is it possible to configure PythonWin so that child windows (for code, for instance) occupy the entire client window? 2. When I launch a .py script from Windows Explorer the resulting DOS box closes before I'm able to read about exceptions. How may I change this behaviour of the system? Thanks in advance. Bill _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From mbc2@netdoor.com Tue Jun 19 17:24:45 2001 From: mbc2@netdoor.com (Brad Chandler) Date: Tue, 19 Jun 2001 11:24:45 -0500 Subject: [Tutor] Python and web scripting References: <01061820143700.02862@orion.andromeda> <3B2F5AF8.CF125658@bic.ch> Message-ID: <000601c0f8dc$5acdbc60$111c0d0a@spb.state.ms.us> Does one actually write programs in Python when using Zope? I've looked at Zope briefly, but it looked overly complicated for simple web scripting and I could never wrap my mind around how it was supposed to work. There's something called PSP http://www.ciobriefings.com/psp/ , which stands for Python Server Pages. I think it's supposed to work similar to PHP. It looks promising, but I haven't figured out whether you can use it with Python or whether you have to use the Java implementation of Python called JPython. (Can someone explain the reason for the exisitence of JPython? Why would anyone use it? All I know about Java is the client side web stuff which I hate with a passion). I like programming in python better, but for web scripting it's hard to beat PHP, especially if your using MySQL or PostgreSQL since PHP has some great builtin functions for those databases, better than the ones available for Python in my opinion. I use PHP for all of my web scripting and Python for utility programs that aren't used for the web. You can of course use Python for cgi programs. I've included an example of an extremely simple one below. The first two print statements are mandatory I believe, after that you can program away. I didn't actually need the 'import cgi' line in this example, but keep that module in mind. You place the script in your cgi-bin directory and access it by pointing your browser to http://www.yourdomain.com/cgi-bin/test.py At least that's how I access mine, assuming you named the file test.py and made it executable. #!/usr/bin/python import cgi print "Content-type: text/html" print print """ Hello World! Hello World!
""" ----- Original Message ----- From: "Flynt" To: "Michael" Cc: Sent: Tuesday, June 19, 2001 9:00 AM Subject: Re: [Tutor] Python and web scripting > Michael wrote: > > > > Hi, > > > > I'm new to Python and new to programming. I've done html and a few > > javascripts and was wanting to learn a real programming language. After > > reading up on all the possibilities, I decided to learn Python as my first. > > > > My question is, how is Python used in a web development application. Can it > > be used in the same manner, but instead of PHP? Are there any tutorials / > > books that cover this aspect? > > > > Thanks, > > > > Michael > > > > PS I liked the IDLE tutorial, I've already learned some things from that even > > though it is not finished. > > > > Hi Michael > > > There is a nice package, HTMLgen > (http://starship.python.net/crew/friedrich/HTMLgen/html/main.html), > which helps you a lot writing HTML. > > There is an web application server based entirely on Python, called Zope > (the link is http://www.zope.org/). This is a full featured web > application server framework, for which also a lot of Add-On modules are > already developed to handle special functionalities. > You have to spend some time studying the docs, to see what it is capable > of, but I think it is well worth a try. Because of the use of python, I > think you are moving on much better founded ground than by using PHP, > which might be quicker in the first place to implement but gives not as > much back, when you are going to more involved problems. And, in IMO, > PHP is *web only*, whereas with Python you can work in just all areas. > A comprehensive introduction to Zope will come out right now at New > Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier > (search for "Zope" on amazon). You can have a look at the last draft of > the book at > http://www.zope.org/Members/michel/ZB/ > > HTH > > --- Flynt > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor From wilson@visi.com Tue Jun 19 18:09:31 2001 From: wilson@visi.com (Timothy Wilson) Date: Tue, 19 Jun 2001 12:09:31 -0500 (CDT) Subject: [Tutor] Python and web scripting In-Reply-To: <000601c0f8dc$5acdbc60$111c0d0a@spb.state.ms.us> Message-ID: On Tue, 19 Jun 2001, Brad Chandler wrote: > Does one actually write programs in Python when using Zope? I've looked at > Zope briefly, but it looked overly complicated for simple web scripting and > I could never wrap my mind around how it was supposed to work. Yes, you can write Zope apps directly in Python, but it's not a trivial process. I suspect that some of the PHP-like packages are simpler initially. Of course, using Zope gives you much more power than simply scripting in Python. Like anything else, you have to weigh your needs vs. the complexity of the solution. That said, it's pretty simple to set up some pretty cool Web apps with Python. Check out the Zope book at http://www.zope.org/Members/michel/ZB/. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.org W. St. Paul, MN | | http://slashdot.org wilson@visi.com | | http://linux.com From bill-bell@bill-bell.hamilton.on.ca Tue Jun 19 18:20:46 2001 From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 19 Jun 2001 13:20:46 -0400 Subject: [Tutor] RE: Elementary questions In-Reply-To: Message-ID: <3B2F51AE.14806.3A70BF6@localhost> "Patrick K. O'Brien" wrote: > 1. Right click on the link or menu choice for PythonWin. You will see > an option labeled "Run." Set it to Maximized and PythonWin will launch > in full screen mode. > Sorry about the brevity, but hope that helps. Not at all. Thanks very much for the help. I've been using MSW for a l-o-n-g time. Can't believe that it would never have occurred to me to do that! LOL. Thanks, Patrick! - Bill Bill Bell, Software Developer From michael@exasource.com Tue Jun 19 19:13:06 2001 From: michael@exasource.com (Michael) Date: Tue, 19 Jun 2001 12:13:06 -0600 Subject: [Tutor] Python and web scripting In-Reply-To: <3B2F5AF8.CF125658@bic.ch> References: <01061820143700.02862@orion.andromeda> <3B2F5AF8.CF125658@bic.ch> Message-ID: <01061912130600.01219@orion.andromeda> Hi Flynt, Thanks for the information. I felt like a dummy writing this message last night because after sending it, I found some information on the Python site. I bet I've been on this site at least 15-20 times, but never found the information, because I was always looking under the tutorials section. I also saw the information on Zope and after reading your post regarding the book, decided that I would get it and check it out. Maybe I'll download Zope now and at least try to get it figured out so when it comes time to use it, after I actually know something about programming in Python, There will be less of a learning curve. The reason I picked Python is just like you said, It can be used in a variety of applications. I'm also interested in trying out Glade. It sounds totally awesome. After I go through several of the web tutorials, what book(s) would you, or anyone else reading this recommend? Thanks, Michael > Hi Michael > > > There is a nice package, HTMLgen > (http://starship.python.net/crew/friedrich/HTMLgen/html/main.html), > which helps you a lot writing HTML. > > There is an web application server based entirely on Python, called Zope > (the link is http://www.zope.org/). This is a full featured web > application server framework, for which also a lot of Add-On modules are > already developed to handle special functionalities. > You have to spend some time studying the docs, to see what it is capable > of, but I think it is well worth a try. Because of the use of python, I > think you are moving on much better founded ground than by using PHP, > which might be quicker in the first place to implement but gives not as > much back, when you are going to more involved problems. And, in IMO, > PHP is *web only*, whereas with Python you can work in just all areas. > A comprehensive introduction to Zope will come out right now at New > Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier > (search for "Zope" on amazon). You can have a look at the last draft of > the book at > http://www.zope.org/Members/michel/ZB/ > > HTH > > --- Flynt -- Michael Lewis Exasource Inc. 970.206.4556 "Linux - The final solution" From csmith@blakeschool.org Tue Jun 19 19:17:21 2001 From: csmith@blakeschool.org (Christopher Smith) Date: Tue, 19 Jun 2001 13:17:21 -0500 Subject: [Tutor] A (not so) simple question? Round Robin In-Reply-To: References: Message-ID: Dear Greg, I'm learning Python and this was a good learning exercise. I, too, found the web site that you did and implemented a solution using two lists and a dictionary. Basically the dictionary acts as a matrix which is accessed through a tuple pair. The lists are the two lines of participants; for a given round, the competitors across from each other have their entry in the dictionary filled with the round number. I modified your print-out routine to fit with my data. You can probably tell that I am use to printing out matrices and don't yet know a more Python like way to print out an entire row of my dictionary inone statement. Basically I need to do something like "print all dictionary entries that have i as the first member of the tuple key." Can anyone provide any tips on this? /c Code follows: def roundrobin(n): # Uses the "rotating lines" scheme presented # at http://www.rain.org/~mkummel/stumpers/09feb01a.html # to print a table for a round robin tournament # between n teams which are represented by capital letters. # If n is odd, the "bye" is indicated with a "_". # make lines l=[];m=[];t={};odd=0 if n/2*2 !=n: n=n+1 odd=1 n2=n/2 for i in range(n2): l.append(i) m.append(i+n2) # do the rounds for r in range(n-1): for i in range(n2): t[(l[i],m[i])],t[(m[i],l[i])]=r,r # rotate the lines (this was fun!) l.append(m.pop()) m.insert(0,l.pop(1)) # define team names and print results teams = map(chr,range(65,65+n)) if odd: teams[-1]="_" print " |" + "%4s"*n % tuple(teams) print "--|" + "----"*n for i in range(n): print "%s |" % teams[i], for j in range(n): if i==j: t[(i,i)]=-1 # initialize diagonal # Without the () in the next line, a string+int error is obtained # Also, the trailing comma leaves a space between elements so the # total space is actually 4, not 3, for each round number print "%3d" % (t[(i,j)]+1), print roundrobin(7) # This is the output # # | A B C D E F G _ # --|-------------------------------- # A | 0 2 3 4 1 7 6 5 # B | 2 0 6 3 5 1 4 7 # C | 3 6 0 7 2 5 1 4 # D | 4 3 7 0 6 2 5 1 # E | 1 5 2 6 0 4 7 3 # F | 7 1 5 2 4 0 3 6 # G | 6 4 1 5 7 3 0 2 # _ | 5 7 4 1 3 6 2 0 From wesc@deirdre.org Tue Jun 19 20:19:33 2001 From: wesc@deirdre.org (Wesley Chun) Date: Tue, 19 Jun 2001 12:19:33 -0700 (PDT) Subject: [Tutor] Python and web scripting In-Reply-To: <01061820143700.02862@orion.andromeda> Message-ID: On Mon, 18 Jun 2001, Michael wrote: > > I'm new to Python and new to programming. I've done html and a few > javascripts and was wanting to learn a real programming language. After > reading up on all the possibilities, I decided to learn Python as my first. > > My question is, how is Python used in a web development application. Can it > be used in the same manner, but instead of PHP? Are there any tutorials / > books that cover this aspect? Michael, good question. now by saying "web development" and mentioning PHP, you are focusing specifically on applications run by web servers (and not including subjects like lower-level network programming [sockets] or Internet client programming [FTP, POP3, NNTP, etc.]). Those are a whole 'nother topic on their! Anyhoo, congratulations are still in order for choosing Python after your investigation. The "old"-style way of web development used CGI, however, the need to embedding logic in static HTML data spawned a great-enough demand for tools like ASP, JSP, Cold Fusion, PHP, and even PSP (Python Server Pages). The other way to do it is to use Zope, as some have already mentioned. Currently, there are some books on Zope coming out, and as far as PSP goes, I've only seen a few magazine articles. For basic matters, it may be easiest and most lightweight to use CGI (plus HTMLgen if your HTML is complex). Performance for sites with a good number of hits can be improved by using a Python Apache module such as PyApache or mod_python. Once this solution becomes less productive, then you can migrate to a more "serious" tool such as the ones we just discussed. Good luck, and hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc@baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From michael@exasource.com Tue Jun 19 21:18:33 2001 From: michael@exasource.com (Michael) Date: Tue, 19 Jun 2001 14:18:33 -0600 Subject: [Tutor] Python and web scripting In-Reply-To: References: Message-ID: <01061914183301.01219@orion.andromeda> > Michael, > > good question. now by saying "web development" and mentioning PHP, > you are focusing specifically on applications run by web servers > (and not including subjects like lower-level network programming > [sockets] or Internet client programming [FTP, POP3, NNTP, etc.]). Yes, my primary focus is on applications run by webservers. > Those are a whole 'nother topic on their! Anyhoo, congratulations > are still in order for choosing Python after your investigation. It seemed to be the most versatile language. I was mainly interested in being able to use it in web applications, but as I progress, I like the idea of being able to do a complete application, GUI and all. Glade sounds awesome. > > The "old"-style way of web development used CGI, however, the need > to embedding logic in static HTML data spawned a great-enough demand > for tools like ASP, JSP, Cold Fusion, PHP, and even PSP (Python > Server Pages). The other way to do it is to use Zope, as some have > already mentioned. Currently, there are some books on Zope coming > out, I have been reading the CVS on The ZOPE Book at sourceforge. It sounds great! I'm looking forward to downloading it and playing with it until I can get proficient enough to use it. >and as far as PSP goes, I've only seen a few magazine articles. I've read a couple of things on this too. Maybe by the time I'm actually able to use ZOPE in a real world application, there will be more information available on this subject as well. > > For basic matters, it may be easiest and most lightweight to use > CGI (plus HTMLgen if your HTML is complex). Performance for sites > with a good number of hits can be improved by using a Python Apache > module such as PyApache or mod_python. Once this solution becomes > less productive, then you can migrate to a more "serious" tool such > as the ones we just discussed. I tried using the ApacheToolBox to install all of this, but it failed. I am attempting to do a manual install and see if this works. Currently we are using a PostgreSQL database, PHP and Apache. The guy working on the backend picked PHP becuase he has a strong background in C, but he's already having problems working with arrays and is not sure what to do about it. I'm just looking for alternatives and since I don't have any prior programming predjudices, decided to look at Python. Thanks for the information and at what point in my journey would your book be beneficial? Is it right for a total newbie, or would it be better to do a few tutorials first? Thanks, Michael From cynic@mail.cz Tue Jun 19 21:36:03 2001 From: cynic@mail.cz (Cynic) Date: Tue, 19 Jun 2001 22:36:03 +0200 Subject: [Tutor] Python and web scripting In-Reply-To: References: <01061820143700.02862@orion.andromeda> Message-ID: <5.1.0.14.2.20010619221645.01fa3230@mail.cz> Hi there, At 21:19 19.6. 2001, Wesley Chun wrote the following: -------------------------------------------------------------- >good question. now by saying "web development" and mentioning PHP, >you are focusing specifically on applications run by web servers >(and not including subjects like lower-level network programming >[sockets] or Internet client programming [FTP, POP3, NNTP, etc.]). >Those are a whole 'nother topic on their! Anyhoo, congratulations >are still in order for choosing Python after your investigation. ------end of quote------ this is not true. PHP has a FTP extension, sockets functions, a c-client extension (access to IMAP, POP3 and NNTP servers)... You can do pretty much anything you might want to do with PHP. cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7 From wesc@deirdre.org Tue Jun 19 22:25:33 2001 From: wesc@deirdre.org (Wesley Chun) Date: Tue, 19 Jun 2001 14:25:33 -0700 (PDT) Subject: [Tutor] Python and web scripting In-Reply-To: <01061914183301.01219@orion.andromeda> Message-ID: On Tue, 19 Jun 2001, Michael wrote: > > It seemed to be the most versatile language. I was mainly interested in > being able to use it in web applications, but as I progress, I like the idea > of being able to do a complete application, GUI and all. Glade sounds > awesome. yes, i have seen a demonstration of GLADE and it looks quite potent. i don't think GUI development had it any easier! > > Currently, there are some books on Zope coming out, > > I have been reading the CVS on The ZOPE Book at sourceforge. It sounds > great! I'm looking forward to downloading it and playing with it until I can > get proficient enough to use it. there is more documentation on Zope now than before, but some still feel it's lacking. i'm interesting in messing around with it more myself. > >and as far as PSP goes, I've only seen a few magazine articles. > > I've read a couple of things on this too. Maybe by the time I'm actually > able to use ZOPE in a real world application, there will be more information > available on this subject as well. > > I tried using the ApacheToolBox to install all of this, but it failed. I am > using a PostgreSQL database, PHP and Apache. The guy working on the backend > picked PHP becuase he has a strong background in C, but he's already having > problems working with arrays and is not sure what to do about it. I'm just > looking for alternatives and since I don't have any prior programming > predjudices, decided to look at Python. Ah, yes. PHP itself is a good concept. unfortunately, it requires learning "yet another language." So this is where PSP and Zope look like better alternatives. In my days at Four11.com and Yahoo!, we used a proprietary PSP-like system to crank our products out. it is definitely the way to go as far as coming up with entire web systems on the fly. Python makes a pretty good first language. The syntax is friendly enough to not scare you away, and you can "add-on" anytime you want. Sort of like having Batman's costume, then adding different gadgets as you see fit. > Thanks for the information and at what point in my journey would your book be > beneficial? Is it right for a total newbie, or would it be better to do a > few tutorials first? Thanks for asking. I will make no attempt to hide the fact that the target audience of Core Python Programming is a technical person who has prior experience in another language (any). I'd suggest doing some of the more well-known programming newbie tutorials: There are several well-known excellent documents pertaining to learning how to program with Python. Most are available from the Python edu-sig website: http://www.python.org/sigs/edu-sig/ Instant Hacking: Learning to Program with Python http://www.hetland.org/python/instant-hacking.php Learning to Program (A. Gauld) http://members.nbci.com/alan_gauld/tutor/tutindex.htm Non-Programmers Tutorial (J. Cogliati) http://www.honors.montana.edu/~jjc/easytut/easytut/ How to Think Like a Computer Scientist (Java and C++ versions by original author A. Downey; and Python version by J. Elkner) http://www.ibiblio.org/obp/thinkCS.html As far as books are concerned, Learn to Program Using Python is an extension of Alan Gauld's tutorial, and Ivan's Teach Yourself Python in 24 Hours are both targeted towards pro- gramming newbies. These books will teach you how to program *using* Python. (anyone have feedback on these BTW?) Once you know how to program, then Core Python can perhaps give you much more insight on *Python* programming. You will probably get a lot out of the Web Programming chapter in particular. Hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc@baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From malex@purdue.edu Tue Jun 19 23:01:25 2001 From: malex@purdue.edu (Oleksandr Moskalenko) Date: Tue, 19 Jun 2001 17:01:25 -0500 Subject: (forw) [wesc@deirdre.org: Re: [Tutor] Python and web scripting] Message-ID: <20010619170125.A18474@purdue.edu> --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=koi8-r Content-Disposition: inline I read Ivan's Python in 24 hours. It was my first book on Python and it left me confused in a few places as I am still a newbie here. I heard your talk at Purdue Linux Users' group which got me really intersted in Python BTW. Anyway, Since I bought Mark's Learning Python and Programming Python 2nd ed. I hit my head quite a few times saying "Oh, that's what Ivan was trying to show!". For example the lambda function was way over my head until I read about it in Learning Python. I guess they are kind of complimentary. Oh, I also read those tutors on the web adn think they are excellent. Alex. --2fHTh5uZTiUOsy+g Content-Type: message/rfc822 Content-Disposition: inline Return-path: Envelope-to: malex@localhost Delivery-date: Tue, 19 Jun 2001 16:41:01 -0500 Received: from oleksa ([127.0.0.1] helo=localhost) by oleksa with esmtp (Exim 3.22 #1 (Debian)) id 15CTF6-0004mq-00 for ; Tue, 19 Jun 2001 16:41:00 -0500 Received: from herald.cc.purdue.edu [128.210.11.29] by localhost with IMAP (fetchmail-5.8.6) for malex@localhost (single-drop); Tue, 19 Jun 2001 16:41:00 -0500 (EST) Received: via tmail-2000(13) for malex; Tue, 19 Jun 2001 16:42:23 -0500 (EST) Received: from mail.python.org (mail.python.org [63.102.49.29]) by herald.cc.purdue.edu (8.11.3/8.11.3/herald) with ESMTP id f5JLgMX00287 for ; Tue, 19 Jun 2001 16:42:22 -0500 (EST) Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org) by mail.python.org with esmtp (Exim 3.21 #1) id 15CTGD-0000cZ-00; Tue, 19 Jun 2001 17:42:09 -0400 Received: from [198.144.195.190] (helo=emperor.deirdre.ORG ident=root) by mail.python.org with esmtp (Exim 3.21 #1) id 15CTFg-0000bu-00 for tutor@python.org; Tue, 19 Jun 2001 17:41:36 -0400 Received: from emperor.deirdre.org (wesc@localhost [127.0.0.1]) by localhost (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0.Beta7-1) with ESMTP id f5JLPYep015664; Tue, 19 Jun 2001 14:25:35 -0700 Received: from localhost (wesc@localhost) by emperor.deirdre.org (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0.Beta7-1) with ESMTP id f5JLPX5O015660; Tue, 19 Jun 2001 14:25:34 -0700 From: Wesley Chun To: Michael cc: Tutor Subject: Re: [Tutor] Python and web scripting In-Reply-To: <01061914183301.01219@orion.andromeda> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: tutor-admin@python.org Errors-To: tutor-admin@python.org X-BeenThere: tutor@python.org X-Mailman-Version: 2.0.5 (101270) Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Discussion for learning programming with Python List-Unsubscribe: , List-Archive: Date: Tue, 19 Jun 2001 14:25:33 -0700 (PDT) On Tue, 19 Jun 2001, Michael wrote: > > It seemed to be the most versatile language. I was mainly interested in > being able to use it in web applications, but as I progress, I like the idea > of being able to do a complete application, GUI and all. Glade sounds > awesome. yes, i have seen a demonstration of GLADE and it looks quite potent. i don't think GUI development had it any easier! > > Currently, there are some books on Zope coming out, > > I have been reading the CVS on The ZOPE Book at sourceforge. It sounds > great! I'm looking forward to downloading it and playing with it until I can > get proficient enough to use it. there is more documentation on Zope now than before, but some still feel it's lacking. i'm interesting in messing around with it more myself. > >and as far as PSP goes, I've only seen a few magazine articles. > > I've read a couple of things on this too. Maybe by the time I'm actually > able to use ZOPE in a real world application, there will be more information > available on this subject as well. > > I tried using the ApacheToolBox to install all of this, but it failed. I am > using a PostgreSQL database, PHP and Apache. The guy working on the backend > picked PHP becuase he has a strong background in C, but he's already having > problems working with arrays and is not sure what to do about it. I'm just > looking for alternatives and since I don't have any prior programming > predjudices, decided to look at Python. Ah, yes. PHP itself is a good concept. unfortunately, it requires learning "yet another language." So this is where PSP and Zope look like better alternatives. In my days at Four11.com and Yahoo!, we used a proprietary PSP-like system to crank our products out. it is definitely the way to go as far as coming up with entire web systems on the fly. Python makes a pretty good first language. The syntax is friendly enough to not scare you away, and you can "add-on" anytime you want. Sort of like having Batman's costume, then adding different gadgets as you see fit. > Thanks for the information and at what point in my journey would your book be > beneficial? Is it right for a total newbie, or would it be better to do a > few tutorials first? Thanks for asking. I will make no attempt to hide the fact that the target audience of Core Python Programming is a technical person who has prior experience in another language (any). I'd suggest doing some of the more well-known programming newbie tutorials: There are several well-known excellent documents pertaining to learning how to program with Python. Most are available from the Python edu-sig website: http://www.python.org/sigs/edu-sig/ Instant Hacking: Learning to Program with Python http://www.hetland.org/python/instant-hacking.php Learning to Program (A. Gauld) http://members.nbci.com/alan_gauld/tutor/tutindex.htm Non-Programmers Tutorial (J. Cogliati) http://www.honors.montana.edu/~jjc/easytut/easytut/ How to Think Like a Computer Scientist (Java and C++ versions by original author A. Downey; and Python version by J. Elkner) http://www.ibiblio.org/obp/thinkCS.html As far as books are concerned, Learn to Program Using Python is an extension of Alan Gauld's tutorial, and Ivan's Teach Yourself Python in 24 Hours are both targeted towards pro- gramming newbies. These books will teach you how to program *using* Python. (anyone have feedback on these BTW?) Once you know how to program, then Core Python can perhaps give you much more insight on *Python* programming. You will probably get a lot out of the Web Programming chapter in particular. Hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc@baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor --2fHTh5uZTiUOsy+g-- From dyoo@hkn.eecs.berkeley.edu Tue Jun 19 23:44:30 2001 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Tue, 19 Jun 2001 15:44:30 -0700 (PDT) Subject: [Tutor] Re: An IDLE Introduction In-Reply-To: Message-ID: On Tue, 19 Jun 2001, Jordan Stanley wrote: > i thinks its great so far > > just a suggestion, how about introducing varibales eg a=3 s=3*a etc > > i'll certainly be coming back to see how the site is going Thanks! Hmmm... This should be in "Day 2 of IDLE", which I'm planning to do sometime soon. The reason I want to keep the "Day 1" page short is to encourage people to look at the Python Introductions on http://python.org/doc/Intros.html, since there's such good documentation there already. Talk to you later! From rol9999@attglobal.net Wed Jun 20 01:39:07 2001 From: rol9999@attglobal.net (Roland Schlenker) Date: Tue, 19 Jun 2001 19:39:07 -0500 Subject: [Tutor] A (not so) simple question? Round Robin References: Message-ID: <3B2FF0AB.492BF1DA@attglobal.net> Christopher Smith wrote: > > Dear Greg, > > I'm learning Python and this was a good learning exercise. > > I, too, found the web site that you did and implemented > a solution using two lists and a dictionary. Basically > the dictionary acts as a matrix which is accessed through > a tuple pair. The lists are the two lines of participants; > for a given round, the competitors across from each other > have their entry in the dictionary filled with the round > number. I modified your print-out routine to fit with > my data. You can probably tell that I am use to printing > out matrices and don't yet know a more Python like way to > print out an entire row of my dictionary inone statement. > Basically I need to do something like "print all dictionary > entries that have i as the first member of the tuple key." > Can anyone provide any tips on this? I think the way you did is just fine. If you are asking how to find all entries that have i as the first member of the tuple key: for k in dict.keys(): if k[0] == i: do something with k > > /c > > Code follows: > > def roundrobin(n): > # Uses the "rotating lines" scheme presented > # at http://www.rain.org/~mkummel/stumpers/09feb01a.html > # to print a table for a round robin tournament > # between n teams which are represented by capital letters. > # If n is odd, the "bye" is indicated with a "_". > > # make lines > l=[];m=[];t={};odd=0 > if n/2*2 !=n: > n=n+1 > odd=1 > n2=n/2 > for i in range(n2): > l.append(i) > m.append(i+n2) > > # do the rounds > for r in range(n-1): > for i in range(n2): > t[(l[i],m[i])],t[(m[i],l[i])]=r,r > > # rotate the lines (this was fun!) > l.append(m.pop()) > m.insert(0,l.pop(1)) > > # define team names and print results > teams = map(chr,range(65,65+n)) > if odd: > teams[-1]="_" > print " |" + "%4s"*n % tuple(teams) > print "--|" + "----"*n > for i in range(n): > print "%s |" % teams[i], > for j in range(n): > if i==j: > t[(i,i)]=-1 # initialize diagonal > # Without the () in the next line, a string+int error is obtained > # Also, the trailing comma leaves a space between elements so the > # total space is actually 4, not 3, for each round number > print "%3d" % (t[(i,j)]+1), > print > > roundrobin(7) > > # This is the output > # > # | A B C D E F G _ > # --|-------------------------------- > # A | 0 2 3 4 1 7 6 5 > # B | 2 0 6 3 5 1 4 7 > # C | 3 6 0 7 2 5 1 4 > # D | 4 3 7 0 6 2 5 1 > # E | 1 5 2 6 0 4 7 3 > # F | 7 1 5 2 4 0 3 6 > # G | 6 4 1 5 7 3 0 2 > # _ | 5 7 4 1 3 6 2 0 > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor Roland Schlenker From emailrassilca@yahoo.com.au Wed Jun 20 00:21:02 2001 From: emailrassilca@yahoo.com.au (emailrassilca@yahoo.com.au) Date: Ñð, 20 èþí 2001 04:36:38 Subject: [Tutor] E-ìàéë áàçû íà îäíîì CD çà 1000 ðóáëåé. Ïðîèçâîäèì ðàññûëêó. Message-ID: Ïðîäàþòñÿ å-ìàéë áàçû íà îäíîì CD çà 1000 ðóáëåé. Áàçà "Ìîñêâà" - 40000 å-ìàéëîâ ôèðì Ìîñêâû. Áàçà "Ðîññèÿ" - 300000 å-ìàéëîâ. + Ïðîãðàììà äëÿ ðàññûëêè. Òàêæå ïî Âàøåìó çàêàçó ïðîèçâåäåì ðàññûëêó. Ïèøèòå: emailrassilka@yahoo.com.au èëè emailrasilka@yahoo.com.au From fasal.waseem@cis.co.uk Wed Jun 20 10:36:47 2001 From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk) Date: Wed, 20 Jun 2001 09:36:47 +0000 Subject: [Tutor] Type Error Message-ID: Hi All Does anybody know where I can get hold of the document for python version 1.5, as I have to use that version and I keep having errors, and I would be very grateful if some one check why am I getting this error. line=string.split(string.strip(line),maxsplit=1) TypeError: this function takes no keyword arguments regards Faz Distributed system support Analyst CIS Miller Street Manchester M60 0AL 0161 837 4487 (office) www.cis.co.uk (our web page) ************************************************************************* This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author. The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes: Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name Registered offices: Miller Street, Manchester M60 0AL Telephone 0161-832-8686 Internet http://www.cis.co.uk E-mail cis@cis.co.uk CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank. CIS & the CIS logo (R) Co-operative Insurance Society Limited ******************************************************************************** From scarblac@pino.selwerd.nl Wed Jun 20 09:51:38 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 20 Jun 2001 10:51:38 +0200 Subject: [Tutor] Type Error In-Reply-To: ; from fasal.waseem@cis.co.uk on Wed, Jun 20, 2001 at 09:36:47AM +0000 References: Message-ID: <20010620105138.A13953@pino.selwerd.nl> On 0, fasal.waseem@cis.co.uk wrote: > Hi All > > Does anybody know where I can get hold of the document for python version > 1.5, as I have to use that version and I keep having errors, and I would be > very grateful if some one check why am I getting this error. > > line=string.split(string.strip(line),maxsplit=1) > TypeError: this function takes no keyword arguments > > regards http://www.python.org/doc/1.5/ In this case the closest translation would be line = string.split(string.strip(line), " ", 1) but that behaves slightly different; the original you have there splits on blocks of whitespace, the translation on single spaces so e.g. >>> string.split("whee whee") ['whee','whee'] >>> string.split("whee whee", " ") ['whee','','','whee'] That may or may not be a problem, depending on what your strings look like (are there multiple spaces between the first word and the rest?) -- Remco Gerlich From fasal.waseem@cis.co.uk Wed Jun 20 11:53:52 2001 From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk) Date: Wed, 20 Jun 2001 10:53:52 +0000 Subject: [Tutor] Thank you Message-ID: Hi Just would like to express my appreciations and thanks to all who sent me the info recently, especially Remco. Regards Faz ************************************************************************* This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author. The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes: Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name Registered offices: Miller Street, Manchester M60 0AL Telephone 0161-832-8686 Internet http://www.cis.co.uk E-mail cis@cis.co.uk CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank. CIS & the CIS logo (R) Co-operative Insurance Society Limited ******************************************************************************** From alan.gauld@bt.com Wed Jun 20 11:00:48 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 20 Jun 2001 11:00:48 +0100 Subject: [Tutor] help for a beginner Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D830@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0F96F.E15D7B60 Content-type: text/plain; charset="ISO-8859-1" I am currently trying to learn the language that is Python. The problem is the last language I ever programmed was BASIC. So I need to know what tools I need to get started I.E. -Start up platform Just the standard Python install will suffice. It comes with everything you need to get started including a rudimentary developmet environment(editor/debugger etc) Can I suggest you pay a visit to my online tutor too which teaches Python alongside BASIC(and Tcl) so you should be able to map your BASIC experience into Python terms quite easily. http://www.crosswinds.net/~agauld -which version to use 2.1 is the latest but I must confess I'm still happily using 2.0. -how to get the screen to let me type the language I am using a compaq 1700T laptop. It is a pentium III and runs at 800mhz. With windows Me. Any help would be useful. Thanks for your time and patience, The Frog ------_=_NextPart_001_01C0F96F.E15D7B60 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable
I am currently trying to learn the language that is = Python.  The=20 problem is the last language I ever programmed was BASIC.  So I = need to=20 know what tools I need to get started I.E.  -Start up = platform
 
Just=20 the standard Python install will suffice. It comes
with=20 everything you need to get started including a
rudimentary developmet = environment(editor/debugger=20 etc)
 
Can I=20 suggest you pay a visit to my online tutor too
which=20 teaches Python alongside BASIC(and Tcl) so you
should be able to map your BASIC experience = into Python=20
terms=20 quite easily.
 
http://www.crosswinds.net/~ag= auld
-which version to use 
 
2.1=20 is the latest but I must confess I'm still happily using=20 2.0. 
-how to get the screen to let me type the language
 
 
I am using a compaq 1700T laptop.  It is a pentium III and = runs at=20 800mhz.   With windows Me.
Any help would be useful.  Thanks for your time and = patience,
=
           &= nbsp;           &= nbsp;           &= nbsp;     =20 The Frog
------_=_NextPart_001_01C0F96F.E15D7B60-- From alan.gauld@bt.com Wed Jun 20 11:26:38 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 20 Jun 2001 11:26:38 +0100 Subject: [Tutor] Python and web scripting Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D831@mbtlipnt02.btlabs.bt.co.uk> > Does one actually write programs in Python when using Zope? Yes. The URLs used to reach a Zope page are actually method calls of python objects. Thus: http://www.azope.server/zoperoot/anobject/amethod is a (fictitious!) URL that calls the amethod() method of an object called "anobject" which is stored in a folder under zoperoot. > Zope briefly, but it looked overly complicated for simple web > scripting It is. There is a simpler version called Poor Man's Zope which might be more appropriate but I've only read the web pages not used it... > There's something called PSP http://www.ciobriefings.com/psp/ > , which stands for Python Server Pages. I think it's > supposed to work similar to PHP. Yes and ASP etc etc... It is server sice scripting embedded within the HTML. > looks promising, but I haven't figured out whether you > can use it with Python or whether you have to use the > Java implementation of Python No it works with regular C Python. > (Can someone explain the reason for the exisitence > of JPython? Why would anyone use it? All I know about Java > is the client side web stuff which I hate with a passion). Leaving passion aside client side Java is the only way to implement stateful cliuent server applications that run in a browser so its very usful. It also performs a lot better than http and provides a much richer computing environment - drag n drop becomes possible for example. Unfortunately Javas programming model is a biit longwinded jython allows you to build a "Java" web client using Python. However the real strength of Jaba nowadays is in server side programming and the huige range of class libraries available for enterprise strength computing. Jython provides access to all of that industry standard code from Python. Its also about the only way to get Java and Python to communicate and with many corporates stanbdardising their computing environment on Java its likely to become even more ubiquitous. Finally a compiled Jython program will run on any platform with a JVM installed - from a mainframe to an embedded system - thats farv more likely than finding a box with python installed(at least for now!) Hopefully some(but not all) of the reasons? > You can of course use Python for cgi programs. Yes and there is an addin to allow embedded cgi which should speed it up considerably since it obviates the need for a new interpreter session each time. There are several books which talk about web programming in Python including the new Programming Python monster volume. Alan G From alan.gauld@bt.com Wed Jun 20 11:32:54 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 20 Jun 2001 11:32:54 +0100 Subject: [Tutor] Python and web scripting Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D832@mbtlipnt02.btlabs.bt.co.uk> > > for tools like ASP, JSP, Cold Fusion, PHP, and even PSP > ... > >and as far as PSP goes, I've only seen a few magazine articles. FWIW it is of course possible to write ASP in Python if you are using an NT/IIS web server with Active Scripting enabled. The winall package contains a script that registers python as an alternative language alongside VBSCript and JSCript. You just spoecify LANGUAGE-Python and then write code inside the usual