Created
July 7, 2012 17:09
-
-
Save LuqueDaniel/3067221 to your computer and use it in GitHub Desktop.
Property use
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
#encoding: utf-8 | |
#!/usr/bin/env python | |
class nueva_clase(object): | |
def __init__(self): | |
self.numero = 2 | |
def mostrar(self): | |
return self.numero | |
def sumar(self, valor): | |
self.numero += valor | |
numeros = property(mostrar, sumar) | |
xd = nueva_clase() | |
print xd.numeros | |
xd.numeros = 22 | |
print xd.numeros | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment