Skip to content

Instantly share code, notes, and snippets.

@ricardosiri68
Created July 17, 2014 00:49
Show Gist options
  • Save ricardosiri68/a0fe391b32814535fbd1 to your computer and use it in GitHub Desktop.
Save ricardosiri68/a0fe391b32814535fbd1 to your computer and use it in GitHub Desktop.
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