Created
July 17, 2014 00:49
-
-
Save ricardosiri68/a0fe391b32814535fbd1 to your computer and use it in GitHub Desktop.
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
class Saludar: | |
__nombre = '' | |
run = True | |
def nombre(self): | |
self.__nombre = raw_input('Inserta un nombre: ') | |
print 'Buenos dias %s !' % self.__nombre | |
def adios(self): | |
self.run = False | |
print 'Adios %s !' % self.__nombre | |
def default(self): | |
print 'comando desconocido' | |
# .lower convierte todos los caraceres de un string en minusculas | |
s = Saludar() | |
commands = { | |
'nombre': s.nombre, | |
'adios': s.adios, | |
'#': s.default | |
} | |
if __name__ == '__main__': | |
while s.run: | |
command = raw_input('> ') | |
commands.get(command, commands['#'])() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment