inner-classes

Python: Inner Class

Python: Inner Class Question: I am trying to create a json string from a class and I defined my class as follows: import json import ast from datetime import datetime import pytz import time class OuterClass: def __init__(self): self.Header = None self.Body = None class Header: def __init__(self, ID = None, Name = None): self.ID …

Total answers: 1

Python – reference inner class from other inner class

Python – reference inner class from other inner class Question: I am trying to reference an inner class from another inner class. I have tried both : class Foo(object): class A(object): pass class B(object): other = A and class Foo(object): class A(object): pass class B(object): other = Foo.A with respective results: Traceback (most recent call …

Total answers: 3

How to access outer class from an inner class?

How to access outer class from an inner class? Question: I have a situation like so… class Outer(object): def some_method(self): # do something class Inner(object): def __init__(self): self.Outer.some_method() # <– this is the line in question How can I access the Outer class’s method from the Inner class? Asked By: T. Stone || Source Answers: …

Total answers: 16