can it be shorter?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Jun 6 11:16:38 EDT 2009


On Sat, 06 Jun 2009 23:07:58 +0800, tsangpo wrote:

> I want to ensure that the url ends with a '/', now I have to do thisa
> like below.
> url = url + '' if url[-1] == '/' else '/'
> 
> Is there a better way?


if not url.endswith('/'):
    url += '/'


-- 
Steven



More information about the Python-list mailing list