i am trying to read a tree structure file in python. I created a class to hold the tree objects. One of the members should hold the parent object. Since the parentObject member is of the same type as the class itself, I need to declare this as an empty variable of type "self".
How do I do that in python?
Thank you very much for your help.
In Python, to write an empty class pass statement is used. pass is a special statement in Python that does nothing. It only works as a dummy statement. However, objects of an empty class can also be created.
In order to define a null variable, you can use the None keyword. Note: The None keyword refers to a variable or object that is empty or has no value. It is Python's way of defining null values.
C++ allows creating an Empty class, yes! We can declare an empty class and its object. The declaration of Empty class and its object are same as normal class and object declaration.
To delete an object in Python, we use the 'del' keyword. A when we try to refer to a deleted object, it raises NameError.
In Python, you don't declare variables as having any type. You just assign to them. A single variable can be assigned objects of different types in succession, if you wanted to do so. "self" is not the type but a naming convention used to refer to the current object, like "this" in Java / C++ (except in Python you could call it anything you wanted).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With