class UrlBuilder:

    def __init__(self, domain, path='blah', params='foo=bar'):
        self.domain = domain
self.path = path
self.params = params

def withPath(self, path):
    self.path = path
return self

def withParams(self, params):
    self.params = params
return self

def __str__(self):
    return 'http://' + self.domain + '/' + self.path + '?' + self.params

def build(self):
    return self.__str__()
if __name__ == '__main__':
    u = UrlBuilder('www.example.com')
print(u.withPath('bobloblaw'))
print(u.withParams('lawyer=yes'))
print(u.withPath('elvis').withParams('theking=true'))
построитель URL для python