code: def from_wif(cls, wif, network=BitcoinMainNet):
          
          # Decode the base58 string and ensure the checksum is valid
          wif = ensure_str(wif)
          try:
              extended_key_bytes = base58.b58decode_check(wif)
          except ValueError as e:
              # Invalid checksum!
              raise ChecksumException(e)
  
          # Verify we're on the right network
          network_bytes = extended_key_bytes[0]
          # py3k interprets network_byte as an int already
          if not isinstance(network_bytes, six.integer_types):
              network_bytes = ord(network_bytes)
          if (network_bytes != network.SECRET_KEY):
              raise incompatible_network_exception_factory(
                  network_name=network.NAME,
                  expected_prefix=network.SECRET_KEY,
                  given_prefix=network_bytes)
  
          # Drop the network bytes
          extended_key_bytes = extended_key_bytes[1:]
  
          # Check for comprssed public key
          # This only affects the way in which addresses are generated.
          compressed = False
          if len(extended_key_bytes) == 33:
              # We are supposed to use compressed form!
              extended_key_bytes = extended_key_bytes[:-1]
              compressed = True
  
          # And we should finally have a valid key
          return cls(long_or_int(hexlify(extended_key_bytes), 16), network,
                     compressed=compressed)
docs: Import a key in WIF format.
  
          WIF is Wallet Import Format. It is a base58 encoded checksummed key.
          See https://en.bitcoin.it/wiki/Wallet_import_format for a full
          description.
  
          This supports compressed WIFs - see this for an explanation:
          http://bitcoin.stackexchange.com/questions/7299/when-importing-private-keys-will-compressed-or-uncompressed-format-be-used  # nopep8
          (specifically http://bitcoin.stackexchange.com/a/7958)