Python - Is it possible to get the name of the chained function?

Posted by user1326876 on Stack Overflow See other posts from Stack Overflow or by user1326876
Published on 2013-10-18T09:40:30Z Indexed on 2013/10/18 9:54 UTC
Read the original article Hit count: 129

Filed under:
|
|

I'm working on a class that basically allows for method chaining, for setting some attrbutes for different dictionaries stored.

The syntax is as follows:

d = Test()
d.connect().setAttrbutes(Message=Blah, Circle=True, Key=True)

But there can also be other instances, so, for example:

d = Test()
d.initialise().setAttrbutes(Message=Blah)

Now I believe that I can overwrite the "setattrbutes" function; I just don't want to create a function for each of the dictionary. Instead I want to capture the name of the previous chained function. So in the example above I would then be given "connect" and "initialise" so I know which dictionary to store these inside.

I hope this makes sense. Any ideas would be greatly appreciated :)

© Stack Overflow or respective owner

Related posts about python

Related posts about oop