How to apply zero-mean pressure update

I’m working on a solver a system coupled with the incompressible Navier-Stokes equations, and at each time step wish to update the computed pressure solution to enforce a zero-mean condition. I’ve figured out that I can compute the zero mean pressure as

p0 = p = assemble(p*dx)

but how can I assign this to my existing pressure function? If I naively try

p.assign(p0)

I get RuntimeError: Expected only linear combinations of Functions in the same FunctionSpaces.

I should also mention that p came from a mixed function space via u, p = w.split() in case that has any bearing.

How about

p0 = assemble(p*dx)
p.vector()[:] -= p0

?

Thanks – I thought I had tried that, and while it didn’t give an error, it didn’t appear to be working either. I tried it a second time and it’s clear it is working.