Skip to content

Instantly share code, notes, and snippets.

@anaved
Last active August 2, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaved/ea43f74cf8643bd2befb71658d1b6942 to your computer and use it in GitHub Desktop.
Save anaved/ea43f74cf8643bd2befb71658d1b6942 to your computer and use it in GitHub Desktop.
Simple partial example
from functools import partial
def power(number, order):
"""This is a power function"""
return number ** order
square = partial( power, order = 2)
cube = partial( power, order = 3)
if __name__ == "__main__":
print square(2)
print cube(2)
>>>4
>>>8
def ssh_execute(host,username,password,command):
connection = ssh_connection(host,port,username,password)
return connection.execute(command)
prod_server = partial(ssh_execute, 'prod_host','prod_username', 'prod_pass' )
dev_server = partial(ssh_execute, 'dev_host','dev_username', 'dev_pass' )
prod_server('whoami')
dev_server('whoami')
>>>prod_user
>>>dev_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment