Skip to content

Instantly share code, notes, and snippets.

@marciojrtorres
Created August 9, 2013 01:20
Show Gist options
  • Save marciojrtorres/6190394 to your computer and use it in GitHub Desktop.
Save marciojrtorres/6190394 to your computer and use it in GitHub Desktop.
Funções variádicas em Python
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