can it be shorter?
no.email at please.post
Sat Jun 6 11:59:37 EDT 2009
In <h0e0oi$1es2$1 at adenine.netfront.net> "tsangpo" <tsangpo.newsgroup at gmail.com> writes:
>I want to ensure that the url ends with a '/', now I have to do thisa like
>url = url + '' if url[-1] == '/' else '/'
>Is there a better way?
It's a pity that in python regexes are an "extra", as it were.
Otherwise I'd propose:
url = re.sub("/?$", "/", url)
kynn (lowest-of-the-low python noob)
More information about the Python-list