I know that you can quickly access the active layer with layer = iface.activeLayer()
Currently I'm working with multiple files in a Python script and my current method of accessing layer extents is this:
layer_file = "/path/to/file"
layer_meta = QFileInfo(layer_file)
layer_title = layer_meta.baseName()
layer = QgsRasterLayer(layer_file, layer_title)
layer.extent()
I'm just wondering if anyone knows a more efficient way to access the extents of a file without having to reproduce these four lines of code for each file