Look in the system console.
As an addendum to the accepted answer, to use self in drivers requires enabling auto-run python scripts. However will also get an invalid expression python error, if ... you have an invalid expression.
When you get an error in a driver expression look at the system console.
Where does console output go
Use self and the slow python expression
Turning off allow auto-run python scripts with use self can lead to invalid expression error.. looking at console.
BPY_driver_eval() - restricted access disallows name 'location', enable auto-execution to support
Error in Driver: The following Python expression failed:
'self.location.x'
Will give a big tip that checking enable auto run fixes this... but as demonstrated here
How to use a custom property of an object as input for a driver? an error in the driver expression can also produce an invalid python expression error message.
So for example accidentally on purpose making a typo
Will look like this with or without auto run python scripts
self.lodation.x
With python auto run OFF error
BPY_driver_eval() - restricted access disallows name 'lodation', enable auto-execution to support
Error in Driver: The following Python expression failed:
'self.lodation.x'
With python auto run ON error
Traceback (most recent call last):
File "<bpy driver>", line 1, in <module>
AttributeError: 'Object' object has no attribute 'lodation'