I am trying to convert some java code to a python equivalent so that I can interface between the two. So in Java I have some code like this:
public int[] toArray(boolean order) {
return toArray(order, this.length());
}
public int[] toArray(boolean order, int length) {
...
}
and a logical equivalent in python might look like this:
def to_array(self, order):
return self.to_array(order, self.length())
def to_array(self, order, length):
...
except... python doesn't allow function overloading, instead it allows for default parameters, so, again, it would seem logical that you would want to do something like this:
def to_array(self, order, length = self.length()):
...
however... this is also not allowed in python, likely since self doesn't really "exist" until within the body of the function.
so what would be the correct way to do this in python? or is it just not possible?
EDIT: I realized I used void functions in my java code that is supposed to return a value so now they return int[]