Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 23, 2013
An "enum" for Python 3
An unexpected perf feature
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
What is to replace Perl then?
Posted Dec 3, 2008 16:33 UTC (Wed) by drag (subscriber, #31333)
All languages are ugly, cludgy, and stupid. Except for those elegant little research languages that are fundamentally worthless for the tasks that most people need to do.
The advantage main advantage of python, it seems to me, is that it's module library. You can now pretty much do anything you want in python...
Web server? Sure
Server side scripting? Sure
OpenGL game programming? Sure
SDL game programming? Yepper skippers.
Scripting language for video games? Ya
Scripting language for graphics applications? Blender; check, Gimp, check. So ok.
GTK programming? Yep.
Scientific visualization? Yes.
Advanced mathmatics? Ya.
Windows programming? Yep.
Realtime physics simulation? yep
.NET programming? Yep.
Hybrid C/Python language for performance? Sure
blah blah blah.
There are modules for everything and anything you'd care to want and the Python 3000 effort is based in reality and is working on maturing the language. The whole 'kitchen sink and batteries included' is the main advantage of it as I see it.
Posted Dec 3, 2008 21:59 UTC (Wed) by jwb (guest, #15467)
Posted Dec 3, 2008 23:00 UTC (Wed) by sbergman27 (guest, #10767)
Ummm... import urlparse and/or urllib? Which have been in the standard library for, oh... years and years? Unless you think those should be builtins?
And the last time I tried to use the python postgresql interface, it was popen()ing psql behind the scenes.
Please show me where this was ever true, if it was ever true, and when. IIRC, historically, there have been pgSQL, psycopg, and psycopg2 modules. Giving you the benefit of the doubt for the time being, *maybe* one of the early ones did that sometime back in the 90s or something. I've certainly never heard of it.
But based upon the level of disinformation I see in your post, it just looks to me like a Perl programmer feeling threatened.
Posted Dec 4, 2008 11:42 UTC (Thu) by niner (subscriber, #26151)
And they say that Perl is bad for there being more than one way to do something.
And still, Perl with it's DBI is the only of the P-scripting languages where essential things
like database access is simple and straight forward.
Posted Dec 4, 2008 17:58 UTC (Thu) by dlang (✭ supporter ✭, #313)
for postgres there is the Pg.pm module as well as the DBI interface.
Posted Dec 4, 2008 23:07 UTC (Thu) by niner (subscriber, #26151)
Honestly, who would be tempted by this ancient module?
Posted Dec 3, 2008 23:06 UTC (Wed) by drag (subscriber, #31333)
For parsing urls though it's simple. From within ipython shell:
In : from urlparse import urlparse
In : url = urlparse('http://lwn.net/Articles/309375/')
In : print url.hostname
In : print url.path
If specified in the string it'll do port, username, and passwords and whatnot.
Posted Dec 3, 2008 23:38 UTC (Wed) by jwb (guest, #15467)
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib2 import urlopen
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/urllib2.py", line 124, in urlopen
return _opener.open(url, data)
File "/usr/lib/python2.5/urllib2.py", line 381, in open
response = self._open(req, data)
File "/usr/lib/python2.5/urllib2.py", line 399, in _open
File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
result = func(*args)
File "/usr/lib/python2.5/urllib2.py", line 1107, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.5/urllib2.py", line 1064, in do_open
h = http_class(host) # will parse host:port
File "/usr/lib/python2.5/httplib.py", line 639, in __init__
File "/usr/lib/python2.5/httplib.py", line 651, in _set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: 'email@example.com'
In Perl the situation is quite satisfactory. The URI module exists and works, and work harmoniously with HTTP::Message and its descendants, which in turn work harmoniously with LWP and WWW::Mechanize and so forth.
Considering python's age and the fact that it has developed coincidentally with the web, you would think that python's web support would be quite mature by now, but it isn't. python's support for basic web operations in quite bad.
Posted Dec 4, 2008 0:15 UTC (Thu) by sbergman27 (guest, #10767)
You mean when you said: "You can do anything you want in python, except the incredibly simple things like parsing URLs."? Yeah, I can see where you might really have meant you have a trivial quibble with the syntax.
Python URL parsing 101, in case anyone is interested:
from urlparse import urlparse
> o = urlparse('http://user:firstname.lastname@example.org:8080/')
Posted Dec 4, 2008 0:17 UTC (Thu) by jwb (guest, #15467)
Posted Dec 4, 2008 2:40 UTC (Thu) by drag (subscriber, #31333)
Posted Dec 4, 2008 3:42 UTC (Thu) by sbergman27 (guest, #10767)
urllib does support this directly:
from urllib import urlopen
> x = urlopen('http://myuser:email@example.com/')
There have, however, been a couple of request nibbles on the issue tracker over the last 4 years or so to add the functionality to urllib2 as well, and no actual opposition to it. Interestingly, there was activity today from a dev saying he was implementing it, noting that it would be trivial to do.
Personally, I think its probably a good idea, but since its just a few lines to handle this case, it doesn't really bother me.
Like I said, this seems something of a cherry-picked example to "prove" that Python's url handling is "not mature". I'm sure that Python and Ruby folks could pick more than a few cherries regarding Perl's problems if they wanted to.
Posted Dec 4, 2008 1:49 UTC (Thu) by jamesh (guest, #1159)
The urllib2 module can perform authentication though, as described in http://docs.python.org/library/urllib2.html#examples
Posted Dec 4, 2008 2:27 UTC (Thu) by jwb (guest, #15467)
Posted Dec 4, 2008 1:43 UTC (Thu) by jamesh (guest, #1159)
Do you remember what module you were using?
Posted Dec 3, 2008 17:08 UTC (Wed) by tjc (subscriber, #137)
My perception is that Ruby is stalled, while Python continues to grow, largely due to Google's App Engine. That said, I'm not a huge Python fan, although I don't hate it either.
Posted Dec 3, 2008 19:45 UTC (Wed) by sbergman27 (guest, #10767)
Posted Dec 3, 2008 20:08 UTC (Wed) by muwlgr (guest, #35359)
Posted Dec 3, 2008 20:07 UTC (Wed) by rfunk (subscriber, #4054)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds