Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. """Programa que permite al usuario ingresar el saludo e imprimirlo en pantalla"""
  5. __author__ = "Gonzalo Chacaltana Buleje"
  6. __version__ = "1.0.1"
  7.  
  8. import sys
  9.  
  10. class HelloWorld(object):
  11. """Clase HelloWorld
  12. Attributes:
  13. greeting (None): Atributo que almacena el mensaje Hola Mundo.
  14. """
  15. greeting = None
  16.  
  17. def __init__(self, greeting):
  18. """Método constructor de la Clase HelloWorld
  19. Args:
  20. greeting (str): Argumento enviado al instanciar la clase.
  21. """
  22. self.greeting = greeting
  23.  
  24. def print(self):
  25. """Método que imprime el mensaje Hola Mundo en pantalla
  26. Returns:
  27. (str) : Mensaje Hola Mundo
  28. """
  29. print ("\n" + self.greeting)
  30.  
  31. if __name__ == '__main__':
  32. # $ > helloWorld.py "Hola Gonzalo"
  33. try:
  34. # Enviamos como parametro el primer valor enviado por consola
  35. # Instanciamos la clase HelloWorld
  36. obj = HelloWorld(sys.argv[1])
  37. #Imprimimos el mensaje enviado por el usuario.
  38. obj.print()
  39. except:
  40. print ("Debe enviar el mensaje al ejecutar programa.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement