I’ve searched a lot, but what I find is mainly examples of recursive programming in python. So here goes the question:
How can I achieve this?
class A:
b = B()
class B:
a = A()
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.
Everything is dynamic in Python – even the class declarations. There’s nothing to stop you modifying the contents of a class after the initial declaration:
NB: If you’re not that familiar with Python, the
passkeyword simply allows you to say ‘nothing here’ – it’s not important unless class A is as empty as it is in this example!