Skip to content

Instantly share code, notes, and snippets.

@anaved anaved/partial.py
Last active Aug 2, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.