Created
November 23, 2015 16:41
-
-
Save leonardocouy/77b265d8819b9f75d217 to your computer and use it in GitHub Desktop.
Example using Classes in Python 2.7
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
class Usuario(): | |
def __init__(self): # construtor/inicializador | |
self.login = "admin" | |
self.senha = 123 | |
def logar(self): # o self se refere ao escopo desta classe (poderei acessar o login e senha e os demais metodos desta classe) | |
l = raw_input("Digite o login: ") | |
if l == self.login : # self.login me refiro a variavel login desta classe. OBS: login != self.login | |
print "Login Correto!" | |
def start(self): | |
self.logar() | |
usuario1 = Usuario() | |
usuario1.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment