Can I use self parameters in my method definition in python?
class Test: def __init__(self, path): self.path = pathlib.Path(path) def lol(self, destination=self.path): x = do_stuff(destination) return x I can make def lol(self, destination) and use it this way test_obj.lol(test_obj.path). But is there a way to set default destination arg to self.path? The other way posted below(based on this answers), but can I refactor it somehow and make it more elegant? Maybe there is new solution in python3.+ versions.
def lol(self, destination=None): if destination in None: destination = self.path x = do_stuff(destination) return x