If I have classes A and B, I basically want to do something like this:
class A:
myDict = {A: 3, B: 2}
Since my reference isn’t in a function, the class hasn’t fully loaded by the time I try to use it. How can I get around this?
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.
The proper solution is to move the dict outside the class
which will result in exactly the values you would get if you could do what you ask for.