replicating in python what the electrum wallet does during (deterministic) wallet creation I am trying to replicate in python what the Electrum wallet does during (deterministic) wallet creation. IMHO the docs are a bit sparse on this one bit maybe because its only performed once for most users, all the tutorials etc. seem to focus on the GUI, and I was unable to work out the python code from the spesmilo github for electrum.

From what I can see, Electrum generates a random Wallet Generation Seed


a 13-word mnemonic(or 12 words plus checksum?)
which is unencrypted This is also the Master Private Key?
Then the user enters a password/passphrase(or not) that encrypts the seed so it can be saved as a wallet(file)
The wallet file can only be decrypted with the password/passphrase
Then a Master Public Key is generated from the wallet [Anybody have more detail on this?].
Then the 25-byte binary Bitcoin Address = 
{[MPK>sha256>RIPEMD160]+[MPK>sha256>RIPEMD160>versionByteadd>sha256>sha256>first4bytes]}
which in turn is Base58Check encoded to the Bitcoin Address format


Can someone please check if my assumptions (1 to 7) are okay/correct me?
Also, below is how far I got with python(probably grossly incorrect!):

from electrum import mnemonic
import ecdsa
import hashlib
import base58
import getpass

mnemonicInstance = mnemonic.Mnemonic(lang='en')
randseed = mnemonicInstance.make_seed()
print "this is my 13 word wallet gen seed" + randseed
private_key = mnemonicInstance.mnemonic_to_seed(randseed , getpass.getpass()).encode('hex')
print "this is my private key: " + private_key
#the line of code below failed!:
sk = ecdsa.SigningKey.from_string(private_key.decode("hex"), curve = ecdsa.SECP256k1)
vk = sk.verifying_key
public_key = ('\04' + vk.to_string()).encode("hex")
print "this is my public key: " + public_key
ripemd160 = hashlib.new('ripemd160')
ripemd160.update(hashlib.sha256(public_key.decode('hex')).digest())
middle_man = '\00' + ripemd160.digest()
checksum = hashlib.sha256(hashlib.sha256(middle_man).digest()).digest()[:4]
binary_addr = middle_man + checksum
addr = base58.b58encode(binary_addr)
print "this is my BTC address: " + addr


(some of the above lifted from Shultzi's github) I also consulted Andreas' Mastering Bitcoin but not had much joy with this bit.
Bip32 is the implementation of hierarchical deterministic wallets. This fully describes what you are discussing here. The full text of bip32 can be found https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
The mnemonic maps to specific bits for the encryption, the words themselves are not used. Read the bit about extending the keys it will also explain how the master public key is generated.  It also explains the three derivations that can be made from the public and private keys which are: 

Parent private key -> child private key

Parent private key -> child public key

Parent public key -> child public key

It is worth noting the child private key cannot be generated from the parent public key.