How to access to data in a multiselection gridcontrol in a database form

I have a database with a form. In this form there is a gridcontrol linked to a table or query.
What I want to do is to be able to select multiple rows in the grid and then access the data (the fields) in those rows.
How would one access the multiple items (rows) selected in a gridcontrol and iterate over them to get the underlying data in a macro?
(I am doing the macros in python, but I suppose if you give me a solution in BASIC I could adapt it)

I’ve found a solution based on this other answer.
My code look like this:

def pruebas(event=None):
	form = event.Source.Model.Parent
	tabla = form.getByName('tblAsistencias')
	vista = XSCRIPTCONTEXT.getDocument().getCurrentController().getControl(tabla)
	selec = vista.getSelection()
	xray(form)
	for s in selec:
		form.absolute(s)
		mensaje(form.Columns.getByName('AsId').getString())
	return