If you don't care about using unaudited features you can use this:
w3.eth.account.enable_unaudited_hdwallet_features()
account = w3.eth.account.from_mnemonic("hello john pizza guitar")
print(account.address)
I couldn't find any mention of the unaudited features in the docs, but simply viewing the attributes of this (account) object I could find you have the following attributes:
- address
- encrypt
- key
- privateKey
- signHash
- signTransaction
- sign_message
- sign_transaction
full list (including private attributes):
['__abstractmethods__', '__bytes__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_address', '_key_obj', '_private_key', '_publicapi', 'address', 'encrypt', 'key', 'privateKey', 'signHash', 'signTransaction', 'sign_message', 'sign_transaction']
You should probably not use this account object to sign transactions as it is undocumented and in all examples of the docs, transactions are usually signed with private keys using web3.eth.sign_transaction(txn, key). You would have a hard time finding information about this object and its features, I stumbled upon this function accidentally thanks to vscode auto-completeion
Instead, use this to retrieve the private key and use it as seen in the docs
pk = account.privateKey