[techtalk] Re: python re.sub help

Tessa Lau tlau at cs.washington.edu
Wed Jan 26 13:55:50 EST 2000

This appears to work for me (Python 1.5.2):
>>> var_a = ""
>>> var_b = "http://www.lazygirl.com"
>>> var_a = re.sub("", var_b, var_a)
>>> var_a

What do you think is wrong?

> var_a = re.sub("", "%s", var_a) % var_b

The proper syntax would be
	var_a = re.sub("", "%s" % var_b, var_a)

Also look at the urlparse module, for a cleaner way to do this kind of URL

techtalk at linuxchix.org   http://www.linuxchix.org

More information about the Techtalk mailing list