Hi, i am brand new in Python, so sorry if this question is too basic, but i have tried a lot and dont have success... I have the following code...
class Funcoes: def CifradorDeCesar(mensagem, chave, funcao): mensagem_encriptada='' if funcao == 1: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)+chave) if byte.isupper() and ord(byte_encriptado) > 90: byte_encriptado=chr(ord(byte_encriptado)-26) if byte.islower() and ord(byte_encriptado) > 122: byte_encriptado=chr(ord(byte_encriptado)-26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado else: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)-chave) if byte.isupper() and ord(byte_encriptado) < 65: byte_encriptado=chr(ord(byte_encriptado)+26) if byte.islower() and ord(byte_encriptado) < 97: byte_encriptado=chr(ord(byte_encriptado)+26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado return mensagem_encriptada class MC(Funcoes, type): def __init__(cls, clsname, bases, ns): def addtrace(f): def t(self, *args, **kwargs): for att in self.__crypt__: atribcripto = getattr(self, att) atribdescripto = Funcoes.CifradorDeCesar (atribcripto, 3, 2) setattr(self, att, atribdescripto) ret = f(self, *args, **kwargs) for att in self.__crypt__: atribdescripto = getattr(self, att) atribcripto = Funcoes.CifradorDeCesar (atribdescripto, 3, 1) setattr(self, att, atribcripto) # aqui seta __signature__ vazio, assina e atribui __signature__ return ret return t from types import FunctionType for name,obj in ns.items(): if type(obj) == FunctionType: setattr(cls, name, addtrace(ns[name])) class C(): __metaclass__ = MC __crypt__ = ["_a", "_b"] _a = 1 _b = 2 def add(self, a, b): _a = a _b = b return a+b then i call >>> i = C() >>> i.add(2,2) and the error: File "C:\Users\Junior\Desktop\Python\T2.py", line 37, in t atribdescripto = Funcoes.CifradorDeCesar(atribcripto, 3, 2) TypeError: unbound method CifradorDeCesar() must be called with Funcoes instance as first argument (got int instance instead) -- http://mail.python.org/mailman/listinfo/python-list