Skip to content

Instantly share code, notes, and snippets.

@FernandoEscher
Created January 24, 2011 05:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save FernandoEscher/792865 to your computer and use it in GitHub Desktop.
Atributos dinámicos en Python
class Dummy(object):
def __getattribute__(self, name):
f = lambda: 'hola con %s'%name
return f
@lfborjas
Copy link

Sos un genio man, sólo como referencia, aquí está algo así en ruby:

class Dummy
    def self.method_missing(name, *args, &block)
         "hola con #{name.to_s}"
    end
end

En ruby todo es método así que no es necesario usar lambda :)

@FernandoEscher
Copy link
Author

Excelente! Deberíamos de tener gists de todas las loqueras que nos ponemos a probar! :P

@lfborjas
Copy link

Mucho relajo guardar todas las urls de los gists, mejor esto: http://escolarea.codepad.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment