Extend C++ OO methods in python -


i require documentation/example extend c++ methods in python. went through python documentation , existing questions on forum, did not exact details.

to precise, if have classes c++:

class manager {  manager *instance; std::list<user*> userlist; manager(); public: user* getuser(const char* name); static manager* getinstance();   }  class user {  user(); public: void dosomething();  } 

in python expect like:

m = getinstance() u=m.getuser('x') u.dosomething() 

so way write python wrapper methods internally call above methods. able write wrapper methods in non object oriented way. ie: able write can call stand alone methods getuser('x') , dosomething(), not object based ones m.getuser('x') , u.dosomething().

by doing m = getinstance(), suppose want object instance. define constructor class. add self calls method particular object only

class manager:      def __init__(self, args):         self.user_list = [] # list of user      def get_user(self, user_name):         return user('user_name') # search here instead   class user:      def __init__(self, args):         self.args = args      def do_something(self):         print("doing!")  m = manager(1) u = m.get_user('x') u.do_something() 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -