'How to send max spendable eth in web3py

I am using python3 and the web3py library.

I want to send the max spendable eth of an account, through the send_raw_transaction function.

At the moment I can fetch the users balance, but I cannot send all that since max spendable eth is balance - gas, but I am not sure how to account for gas.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source