It appears as if variables can be located both inside and outside the if __name__ == "__main__": block. In this case I place a file path variable within the if block. However, the code works if I place the path variable outside the if block too.
def do_something(path):
print(path)
if __name__ == "__main__":
path = '/path/to/my/image.tif'
do_something(path)
Are there any Python standards that dictate whether or not variables such as path should be placed inside or outside the if __name__ == "__main__": block?
Aucun commentaire:
Enregistrer un commentaire