Well, an alternative /could/ be:
from urlparse import urlparse
parts = urlparse('http://alongnameofasite1234567.com/q?sports=run&a=1&b=1')
print '%s%s_%s' % (parts.netloc.replace('.', '_'),
parts.path.replace('/', '_'),
parts.query.replace('&', '_').replace('=', '_')
)
Although with the result of:
alongnameofasite1234567_com_q_sports_run_a_1_b_1
1288 function calls in 0.004 seconds
Compared to regex method:
498 function calls (480 primitive calls) in 0.000 seconds
I'd prefer the regex method myself.
Demian Brecht
http://demianbrecht.github.com
On 2013-02-06 1:41 PM, "rh" <[email protected]> wrote:
>http://alongnameofasite1234567.com/q?sports=run&a=1&b=1
--
http://mail.python.org/mailman/listinfo/python-list