Re: [Tutor] Defining "bit" type

2009-01-28 Thread Vicent
On Tue, Jan 27, 2009 at 14:26, Ricardo Aráoz wrote: > > "Vicent" wrote > > Anyway, I am working with Python 2.5.4, and I am interested in defining a > new type called "bit" (if possible), which represents a number that can > only > take values 0 or 1 —that's what we would call a "binary variabl

Re: [Tutor] operator, mult

2009-01-28 Thread col speed
Thanks John, That sorted me out, sometimes I just can't get things worked out in my head, then get a sense of "instant enlightenment", which your comments did for me. I am ashamed to say I was using the wrong prime factors function, then changing the mult to mul all started to make sense. Thanks ag

Re: [Tutor] operator, mult

2009-01-28 Thread John Fouhy
2009/1/29 col speed : [...] > What I expected "mult" to do was (somehow)to work out what the powers of > the prime factors would be. Another reason I didn't think it was "mul" is > the part that says " prime_factors_mult(n)" as the prime_factors function > is just "prime_factors(n)" - without th

Re: [Tutor] operator, mult

2009-01-28 Thread col speed
This is a way of finding how many coprimes there are for a number - eg 144 How many positive numbers less than or equal to 144 are relatively prime to 144? Factor 144 = 2 4 × 3 2 . Use the formula for each prime: >From 2 4 , we get 2 - 1 = 1 and 2 4 - 1 = 2 3 = 8. >From 3 2 , we get 3 - 1 = 2

Re: [Tutor] configuring web browser PP3E

2009-01-28 Thread James Mills
On Thu, Jan 29, 2009 at 12:17 PM, bmol...@att.net wrote: > yes, i'm running on Mac OS X / Unix, but i'm afraid i don't know "where" to > change the port to 80. i'm working with the following files straight from > the book 'Programming Python': You're not blind are you ? Because I am. > cgi101.p

[Tutor] building Python 2.6?

2009-01-28 Thread Bernard Rankin
Hello, I am trying to build python 2.6 on a machine (web server) that I do not have root access to. (has 2.4 installed) Python 2.5 builds fine, but I am getting an error when I run "make" for 2.6.1 Here is the command line I am using: ../configure -prefix=/home/username/local-python/ --enable-u

Re: [Tutor] configuring web browser PP3E

2009-01-28 Thread James Mills
On Thu, Jan 29, 2009 at 11:31 AM, bmol...@att.net wrote: > Traceback (most recent call last): > File "webserver.py", line 22, in ? >srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/SocketServer.py", > line

[Tutor] configuring web browser PP3E

2009-01-28 Thread bmol...@att.net
hi. i'm reading 'Programming Python' and having some trouble with adding a web interface in chapter one. (page 72) basically, i open the cgi101.html file in Firefox. i enter a name and hit Submit Query: but instead of getting the Hello "name"! page returned to me I get the error page.

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Justin Ezequiel
> How insane that XP doesn't search the text in "non text" files! > > -- > Alan Gauld http://support.microsoft.com/default.aspx?scid=KB;EN-US;q309173 I used Method 2 under Resolution recently when I reinstalled XP on a new harddisk. HTH ___ Tutor maill

[Tutor] IDLE vs PythonWin

2009-01-28 Thread Wayne Watson
Title: Signature.html About three weeks ago I decided to give PythonWin a whirl. I believe I've noticed about as many code "wrecks" as with IDLE. That is, while working repeatedly on a program, the editor got confused about what it had available, usually remnants of previous code. I just trie

Re: [Tutor] Python grep

2009-01-28 Thread Alan Gauld
"Kent Johnson" wrote Since there have been a couple of threads about searching recently, I thought this might be of interest: http://www.redmountainsw.com/wordpress/archives/python-grep I'll throw in PowerGrep which is a grep like tool that knows about multiple file formats such as MS Offic

Re: [Tutor] To Arc (PIL) or Not to Arc (Tkinter)

2009-01-28 Thread Alan Gauld
I think PIL came first, and apparently depended upon some then present elements of Python for displaying images. I'm pretty sure Tkinter came before PIL. Tkinter has been around since at least Python 1.3, and I think maybe even 1.2.X! I don't think PIL appeared till about v2.0 But PIL is not,

Re: [Tutor] Finding the End of a Def?

2009-01-28 Thread Wayne Watson
I'm sure with a refresher on Perl, I could write code to do it. However, I'll just use my eyes. Ricardo Aráoz wrote: Wayne Watson wrote: I'm not at all tempted (binding). VBG. Page scroll and a steady eye on the left margin works well for my current purposes. However, I am

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Alan Gauld
"W W" wrote You know, it probably wouldn't be terribly difficult to write the search in python. Then you *could* find strings inside rather easily. Given that there's findstr in DOS and grep in *nix(and for DOS too!) it hardly seems worthwhile reinventing that particular wheel! :-) But the

Re: [Tutor] Defining "bit" type

2009-01-28 Thread Ricardo Aráoz
> "Vicent" wrote > >> Anyway, I am working with Python 2.5.4, and I am interested in >> defining a >> new type called "bit" (if possible), which represents a number that >> can only >> take values 0 or 1 —that's what we would call a "binary variable", in a >> Mathematical Programming context. The

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Kent Johnson
On Wed, Jan 28, 2009 at 1:29 PM, Wayne Watson wrote: > These look Linux based. > > Kent Johnson wrote: > Other than being written in Perl ;-) ack is a nice command-line search tool: > http://petdance.com/ack/ > > or the Python equivalent: > http://pypi.python.org/pypi/grin No, they are Perl and

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Kent Johnson
On Wed, Jan 28, 2009 at 10:56 AM, W W wrote: > You know, it probably wouldn't be terribly difficult to write the search in > python. Then you *could* find strings inside rather easily. Other than being written in Perl ;-) ack is a nice command-line search tool: http://petdance.com/ack/ or the Py

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread W W
You know, it probably wouldn't be terribly difficult to write the search in python. Then you *could* find strings inside rather easily. HTH, Wayne On Wed, Jan 28, 2009 at 9:30 AM, Wayne Watson wrote: > Thanks. I'll post a msg to a XP group about this. I suspect Python hashes > the code somehow.

Re: [Tutor] To Arc (PIL) or Not to Arc (Tkinter)

2009-01-28 Thread Kent Johnson
On Wed, Jan 28, 2009 at 10:30 AM, Wayne Watson wrote: > Thanks. I was beginning to think the only way to get this done is via > Tkinter's canvas. > > I guess I can see why PIL later became amended with libraries like Tkinter. > I think PIL came first, and apparently depended upon some then present

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Wayne Watson
Title: Signature.html Thanks. I'll post a msg to a XP group about this. I suspect Python hashes the code somehow. Findstr? Wow, that's got to be old. Where did you find that? Alan Gauld wrote: "Wayne Watson" wrote Just using the standard Win XP Pro folder search. I target the folder wi

Re: [Tutor] To Arc (PIL) or Not to Arc (Tkinter)

2009-01-28 Thread Wayne Watson
Title: Signature.html Thanks. I was beginning to think the only way to get this done is via Tkinter's canvas. I guess I can see why PIL later became amended with libraries like Tkinter. I think PIL came first, and apparently depended upon some then present elements of Python for displaying im

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Tim Golden
Alan Gauld wrote: "Wayne Watson" wrote Just using the standard Win XP Pro folder search. I target the folder with my py programs, use *.py to search, and specify I'm looking for angle in the files it finds. Yes, I get the same behaviour! I tried searching for 'import' which should be almost

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Alan Gauld
"Wayne Watson" wrote Just using the standard Win XP Pro folder search. I target the folder with my py programs, use *.py to search, and specify I'm looking for angle in the files it finds. Yes, I get the same behaviour! I tried searching for 'import' which should be almost every file! It came

Re: [Tutor] To Arc (PIL) or Not to Arc (Tkinter)

2009-01-28 Thread Kent Johnson
On Wed, Jan 28, 2009 at 8:25 AM, Wayne Watson wrote: > I've been playing with PIL and Tkinter a bit, and see that PIL does not have > any facility to view the image file I draw on. I open a file from my folder > with a py program as an Image. The only way, without using some other > module, is to

Re: [Tutor] To Arc (PIL) or Not to Arc (Tkinter)

2009-01-28 Thread Wayne Watson
Title: Signature.html I've been playing with PIL and Tkinter a bit, and see that PIL does not have any facility to view the image file I draw on. I open a file from my folder with a py program as an Image. The only way, without using some other module, is to save the changed file, then display

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-28 Thread Wayne Watson
Title: Signature.html Just using the standard Win XP Pro folder search. I target the folder with my py programs, use *.py to search, and specify I'm looking for angle in the files it finds. Kent Johnson wrote: On Sun, Jan 25, 2009 at 10:31 AM, Wayne Watson wrote: If I open a fol

Re: [Tutor] How Do I Put an Image on a Canvas and Display it?

2009-01-28 Thread Wayne Watson
Well, I new one day I'd have to understand namespaces better. VBG. Your article and others helped. I'm not sure I understand the print42 example. Is it that the name is produced in the first module, and the body of the it isn't available to the second module?  I'll post in a few minutes a comm

Re: [Tutor] Handling post request

2009-01-28 Thread Alan Gauld
"Tiago Katcipis" wrote thank you all for the help but i have finnaly been able to do what i wanted. I will not use CGI scripts, its very simple what im doing and i just wanted the parameters sent on the POST like: * "name1=value1&name2=value2&name3=value3"* The cgi module would have given

[Tutor] Python grep

2009-01-28 Thread Kent Johnson
Since there have been a couple of threads about searching recently, I thought this might be of interest: http://www.redmountainsw.com/wordpress/archives/python-grep Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tuto

Re: [Tutor] Handling post request

2009-01-28 Thread Tiago Katcipis
thank you all for the help but i have finnaly been able to do what i wanted. I will not use CGI scripts, its very simple what im doing and i just wanted the parameters sent on the POST like: * "name1=value1&name2=value2&name3=value3"* but reading about CGI i discovered that the size of these param

Re: [Tutor] Handling post request

2009-01-28 Thread Justin Ezequiel
> From: Tiago Katcipis > > I am trying to make a small HTTP server on python just to handle some POST > and GET requests. I never worked with http before and dont know if i am > doing something completely stupid (probably yes). I read anything possible > already and i just cant find how i access t

Re: [Tutor] Handling post request

2009-01-28 Thread Tiago Katcipis
actualy i have found what i wanted on the rfile attribute, i already tried before to read it but the application just freezes when i try to read() or readline() on it. But after i make the request, and both client and server sides freezes, if i kill the client side the server becomes able of readin

Re: [Tutor] Handling post request

2009-01-28 Thread Tiago Katcipis
thanks for the help, im really not used on doing web stuff, ill try reading the how to. On Wed, Jan 28, 2009 at 9:03 AM, Alan Gauld wrote: > "Tiago Katcipis" wrote > > I am trying to make a small HTTP server on python just to handle some POST >> and GET requests. I never worked with http before

Re: [Tutor] Handling post request

2009-01-28 Thread Alan Gauld
"Tiago Katcipis" wrote I am trying to make a small HTTP server on python just to handle some POST and GET requests. I never worked with http before and dont know if i am doing something completely stupid (probably yes). Not stupid so much as overly complicated. The cgi module will do all t

[Tutor] Handling post request

2009-01-28 Thread Tiago Katcipis
I am trying to make a small HTTP server on python just to handle some POST and GET requests. I never worked with http before and dont know if i am doing something completely stupid (probably yes). I read anything possible already and i just cant find how i access the information sent on the POST re

Re: [Tutor] operator, mult

2009-01-28 Thread Alan Gauld
"col speed" wrote I got the following function while googling: def totient(n): from operator import mult if n == 1: return 1 return reduce(mult, [(p-1) * p**(m-1) for p,m in prime_factors_mult(n)]) I already have the "prime_factors" function. The problem is that I cannot find "mu