Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am calling a class from Python in C++. While creating instance of a class such that pInstance = Py_CallObject(pClass, NULL), How to pass arguments to instances using PyObject?
I have a constructor in python such that I have to pass arguments when instance is created. This is my constructor in Python program
class Model:
	      def Model(self, str1, str2):


What I have tried:

I have created the instance using
pInstance = Py_CallObject(pClass, NULL)
but how to pass arguments to instance
Posted
Updated 24-Sep-18 0:51am
v2
Comments
Member 13909990 25-Sep-18 0:55am    
I am using python 3.5. How to pass arguments while creating instances itself? If there is an example program it will be good

1 solution

See Object Protocol — Python 2.7.15 documentation[^] for the methods to call a Python object.
 
Share this answer
 
Comments
Member 13909990 25-Sep-18 0:50am    
But I am using python 3.5
Richard MacCutchan 25-Sep-18 3:25am    
Then read the Python 3.5 documentation.
Member 13909990 25-Sep-18 0:53am    
How to pass arguments while creating instance itself?
Member 13909990 25-Sep-18 0:54am    
If there is an example program it will be good

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900