In Python, if I have an object, say x, then how do I create a new object y so that x and y are of the same class?
In Java, the code I want would look something like this:
Object y = x.getClass().newInstance();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could probably do something like:
or
And, if you’re wondering how to make a new style class, all you need to do is inherit from
object(or use python 3.x)