I am new to python and I'm wondering how one would go around to convert a piece of code in this case Java to python. For instance if a public class Example is a class which consists of multiple functions for instance:
File 1:
public class Example{
private ArrayList<Something> somethings;
private boolean test;
foo(){
test= false;
somethings = new ArrayList<>();
}
.
.
.
File 2:
class Something{
private Example another;
private String whatever;
Something(String a, Node another){
this.another = another ;
this.whatever = whatever;
}
.
.
.
In python what is the equivalent of import java.util.ArrayList; and how would one go about it to call another class?
Will this be some sort of the above's equivalent in python? How would I go about linking the 2 classes together in python?
class Example():
def __init__(self):
self.test= False
self.somethings= []
.
.
.
class Something:
def __init__(self, another, whatever):
self.another = another
self.whatever = whatever
.
.
.
Thanks in advance
EDIT 1: My questions mainly are If the implementation of that piece of code are correct and how to call a class within a class in python
EDIT 2:Thanks for everyone who answered so far. Just to clarify with one more thing if I had something like which is in class Example:
void exampleSomething(Example exampleb, String a){
somethings.add(new Something(a, another));
}
in python would this be the following:
def exampleSomething(another, a):
self.somethings.append(a, another)
Thanks once again
ArrayListin Python?