Giter Club home page Giter Club logo

Comments (3)

GrahamDumpleton avatar GrahamDumpleton commented on July 26, 2024

I can't see how what you are doing will work, as you never have an instance of the target class. When the decorators are applied, it is at the point where the class is being declared. It is only later you would have instances of them. You therefore have no way of ever knowing what the instance is.

I suspect that you might need to use metaclasses in addition to decorators. Although the decorators wouldn't need to use wrapt as they are just going to annotate functions they are applied to with extra information which would then be checked when the meta class is used to create the instance of the class.

from wrapt.

stuaxo avatar stuaxo commented on July 26, 2024

So, with this method any classes wanting to use the decorator would need to use my metaclass ?

from wrapt.

stuaxo avatar stuaxo commented on July 26, 2024

Ah ... I see the hole in my logic - while I might be able to do this and get the class, it can't work with instances .. as I wouldn't know which instance to call the method on.

Cheers for the info, decorators + metaclasses is a recipe for fun at the best of times.

from wrapt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.