I have to trasform a script (which I didn't write myself) from QGIS to ArcMap.

In the script a filter by expression is used. The function has the input inl (= the layer with the data that should be filtered) and filter (a string e.g. 'HQ_SZEN<=30' / '"HQ_SZEN"<=30'). This filter is a user input and in QGIS one has to use the second form. I think ArcMap requires the same input but it didn't seem to work so I tried to use arcpy.AddFieldDelimiters with the first form like mentioned in example 4 here https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm. To use this I had to split the attributename from the actual expression and my reasoning was that there would always be a strange character between the name and the expression. So that is the reason why the arcpy code is kind of ugly with the chars_allowed_in_layername.

I was thinking of solving it by using arcpy.da.SearchCursor with a where clause but I can't get the filter to work. As filter i use 'HQ_SZEN <=30', the output I get is:

EDIT: just using quotation marks in the input (so filter = '"HQ_SZEN"<=30') is acceptable in my script and it makes the code a lot cleaner because all the stuff about extracting the fieldname from the filter becomes unnecessary.