Created
November 21, 2012 23:30
-
-
Save jbochi/4128533 to your computer and use it in GitHub Desktop.
exemplo de partial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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