[prog] Re: [Techtalk] How to write web proxy in Python?

jennyw jennyw at dangerousideas.com
Thu Jan 9 16:04:47 EST 2003


Others may disagree, but I find that both languages are reasonably
comparable in terms of ability to finish tasks.  The big difference is
syntax and coding style -- it's generally a lot easier to read a
random stranger's Python code than a random stranger's Perl code.  And
also available libraries.

Perl's motto is "there's more than one way to do it"; Python's is
"there's usually only one (good) way to do it.".  Python is one of the
few languages that requires indentation (in fact, there are no curly
braces for separating blocks -- it's all done by indentation). 

At one point it was a lot easier to find modules for Perl than for
Python, but Python has been gaining in popularity 

Another language you might want to compare with is Ruby. Ruby is newer
than either Perl or Python and there are a lot of OO programmers
(including Smalltalkers) are enthusiastic about it.

Jen


On Thu, Jan 09, 2003 at 01:53:57PM -0800, Nancy Ging wrote:
> I have a question--what is the difference, in terms of how and when you
> would use each--between python and perl? I've done lots of perl programming
> but never taken a look at python. Is there a good reason to do so?
> 
> Thanks,
> 
> Nancy Ging
> Turtle Island Web Design
> http://www.turtlehome.com/
> An island of vision in a sea of technological possibilities...
> 
> -----Original Message-----
> From: programming-admin at linuxchix.org
> [mailto:programming-admin at linuxchix.org]On Behalf Of Amanda Babcock
> Sent: Thursday, January 09, 2003 1:47 PM
> To: programming at linuxchix.org
> Subject: Re: [prog] Re: [Techtalk] How to write web proxy in Python?
> 
> 
> On Fri, Jan 10, 2003 at 08:16:18AM +1100, Mary wrote:
> 
> > LinuxChix has a programming list, so I've Cc-ed them.
> 
> Oh, I never thought of sending to programming :)  Oops.
> 
> > I would suggest using something higher level than sockets if you
> > possibly can, unless the assignment requires sockets.
> 
> It's not an assignment.  My university's online instruction system is
> awful and is confusing Opera :(  I'm trying to work around that.
> 
> > Python has a
> > socket module which is easier to use than the C one - it is slightly
> > higher level and handles some of the errors itself, so I'd recommend it
> > over C, since you've never programmed sockets before.
> 
> I actually found the Python socket tutorial, and it looks like pie.
> (http://www.amk.ca/python/howto/sockets/)
> 
> > If the assignment doesn't require sockets, Python has an httplib module
> > that might be appropriate, which will open connections for you without
> > you needing to open and use sockets yourself.
> >
> > You might even be able to use the urllib module instead, which will
> > fetch a url for you with a single line of code.
> 
> My goal is for the proxy to be completely transparent except for fixing
> the bad Javascript the university is sending me.  It actually seems to
> me that using just the sockets would be easier since I can effectively
> just let my browser and the university talk to each other, stepping in
> only to fix ^M to ^J.  If I just plug sockets into each other, I don't
> even need to *know* the URL (just the hostname and port :)
> 
> > To make the proxy, I would suggest you look at Python's SimpleHTTPServer
> > module, or maybe BaseHTTPServer and override some methods,
> 
> Hmm.  That sounds like more work.
> 
> > your replacement (Python's string module will handle the replacement).
> 
> Thanks!  I hadn't got around to how to do the replacement yet :)  Good
> to know where to find it.
> 
> > For a beginning Python programmer, I'd suggest working through the
> > tutorial at http://www.python.org/doc/current/tut/tut.html
> 
> Cool!
> 
> > All modules I've mentioned are documented at
> > http://www.python.org/doc/current/modindex.html
> 
> Thanks!  I'll let everybody know how it goes.
> 
> Amanda
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
> 
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
> 
> 



More information about the Programming mailing list