From c21499d78ab145f20a307aba33b61d6327e66afd Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Tue, 12 Nov 2024 18:16:00 +0100 Subject: [PATCH] [test project] class in function, classes and methods --- .../project1/src/moduleWithClasses.py | 30 +++++++++++++++++++ .../project1/src/root/subpackage1/__init__.py | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 resources/examples/project1/src/moduleWithClasses.py diff --git a/resources/examples/project1/src/moduleWithClasses.py b/resources/examples/project1/src/moduleWithClasses.py new file mode 100644 index 0000000..d0ce3aa --- /dev/null +++ b/resources/examples/project1/src/moduleWithClasses.py @@ -0,0 +1,30 @@ +def function_with_class_inside(): + class ClassInFunction: + def __init__(self): + self.varInClassInFunction = False + + c = ClassInFunction() + return c.__dict__ + + +print(function_with_class_inside()) + + +class ClassWithClasses: + class ClassInClass: + def __init__(self): + self.varInClassInClass = 3 + + print(ClassInClass()) + + def __init__(self): + class ClassInMethod: + def __init__(self): + self.varInClassInMethod = 5 + + print(ClassInMethod().varInClassInMethod) + self.varInClassWithClasses = 4 + + +c = ClassWithClasses() +print(c.__dict__) diff --git a/resources/examples/project1/src/root/subpackage1/__init__.py b/resources/examples/project1/src/root/subpackage1/__init__.py index 1a96b86..7ffe821 100644 --- a/resources/examples/project1/src/root/subpackage1/__init__.py +++ b/resources/examples/project1/src/root/subpackage1/__init__.py @@ -4,4 +4,4 @@ class ClassInSubpackage: def __init__(self): - self.varInClassInSubpackage = True + self.varInClassInSubpackage = True \ No newline at end of file