Created
August 9, 2013 01:20
-
-
Save marciojrtorres/6190394 to your computer and use it in GitHub Desktop.
Funções variádicas em Python
This file contains 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
def caminhoPao(separador, nivel1, *demaisNiveis): | |
caminho = [nivel1] | |
caminho.extend(demaisNiveis) | |
return " > ".join(caminho) | |
print caminhoPao(">") # este falha, o primeiro nivel eh obrigatorio | |
print caminhoPao(">", "Home") | |
print caminhoPao(">", "Home", "Eletronicos", "TV's", "LED") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment