Making Non Callable Objects Callable

Discussion in 'Python' started by exiquio, Oct 7, 2008.

  1. exiquio

    exiquio Guest

    I am trying to figure out if there is a way to make an object in
    python callable, modules in particular. I wrongly assume that defining
    '__call__' in the the objects __dict__ would work. Any help would be
    appreciated.
     
    exiquio, Oct 7, 2008
    #1
    1. Advertising

  2. exiquio

    exiquio Guest

    On Oct 7, 1:56 pm, Christian Heimes <> wrote:
    > exiquio wrote:
    > > I am trying to figure out if there is a way to make an object in
    > > python callable, modules in particular. I wrongly assume that defining
    > > '__call__' in the the objects __dict__ would work. Any help would be
    > > appreciated.

    >
    > No, that doesn't work. Several magic methods (__*__) aren't looked up in
    > __dict__ or through __getattr__().
    >
    > Christian


    Thanks.
     
    exiquio, Oct 7, 2008
    #2
    1. Advertising

  3. exiquio

    exiquio Guest

    On Oct 7, 1:56 pm, Christian Heimes <> wrote:
    > exiquio wrote:
    > > I am trying to figure out if there is a way to make an object in
    > > python callable, modules in particular. I wrongly assume that defining
    > > '__call__' in the the objects __dict__ would work. Any help would be
    > > appreciated.

    >
    > No, that doesn't work. Several magic methods (__*__) aren't looked up in
    > __dict__ or through __getattr__().
    >
    > Christian


    Thanks.
     
    exiquio, Oct 7, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nicolas Fleury

    Make staticmethod objects callable?

    Nicolas Fleury, Feb 28, 2006, in forum: Python
    Replies:
    10
    Views:
    583
    Steven D'Aprano
    Mar 1, 2006
  2. Steven Bethard
    Replies:
    0
    Views:
    274
    Steven Bethard
    Mar 1, 2006
  3. Replies:
    2
    Views:
    360
    Diego Martins
    May 19, 2006
  4. dude

    making a class callable

    dude, Mar 4, 2011, in forum: Python
    Replies:
    3
    Views:
    230
    Tom Zych
    Mar 4, 2011
  5. Ulrich Eckhardt
    Replies:
    6
    Views:
    113
    Peter Otten
    Jul 12, 2013
Loading...

Share This Page