Define a Dirichlet boundary condition for each side and then pass all the bcs to the solve method, i.e.
class East(SubDomain):
def inside(self, x , on_boundary):
return near(x[0], 1.0)
class West(SubDomain):
def inside(self, x , on_boundary):
return near(x[0], 0.0)
class North(SubDomain):
def inside(self, x , on_boundary):
return near(x[1], 1.0)
class South(SubDomain):
def inside(self, x , on_boundary):
return near(x[1], 0.0)
bcs = [DirichletBC(V, Constant(50), East()),
DirichletBC(V, Constant(100), North()),
DirichletBC(V, Constant(150), West()),
DirichletBC(V, Constant(75), South())]
a =...
L = ...
u = Function(V)
solve(a == L, u, bcs=bcs)