Skip to content

Instantly share code, notes, and snippets.

@jbochi
Created November 21, 2012 23:30
Show Gist options
  • Save jbochi/4128533 to your computer and use it in GitHub Desktop.
Save jbochi/4128533 to your computer and use it in GitHub Desktop.
exemplo de partial
#from functools import partial
def partial(funcao, argumento):
def fn(arg):
return funcao(argumento, arg)
return fn
def to_tag(tag, texto):
return "<{tag}>{texto}</{tag}>".format(tag=tag, texto=texto)
negrito = partial(to_tag, 'b')
italico = partial(to_tag, 'i')
print negrito(italico("oi, python brasil"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment