'concatenation TypeError: sequence item 0: expected str instance, list found

i've got a problem with my script when i want to concatenate to an address the layer i want to change. So i use this Script:

import glob
import arcpy
import pathlib
import os
import re




print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\\Esri\ArcGISPro\Favorites\[email protected]"
target = glob.glob(targetPattern)
print(target)

filename = r'\test.geom06.part_voiture'

joiend = [target,filename]
for ready in joiend:
    print(''.join([target,r'\test.geom06.part_voiture']))

print(ready)


couche_voiture = ready


for i in users:
    arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")

    message = "privilege modifié pour " + i + "sur finess"
    print(message)

but when i execute the script i've got this message:

"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" C:/Users//Documents/tian.py
ouverture des droits
Traceback (most recent call last):
  File "C:/Users//Documents/tian.py", line 20, in <module>
    print(''.join([target,r'\test.geom06.part_voiture']))
TypeError: sequence item 0: expected str instance, list found
['C:\\Users\\\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\[email protected]']

Process finished with exit code 1

do you know how i can resolve that?



Solution 1:[1]

target is a list so you need to use join on it too

import glob
import arcpy
import pathlib
import os
import re




print("ouverture des droits")
users = ['geom01', 'geom02']
targetPattern = r"C:\Users\**\AppData\Roaming\\Esri\ArcGISPro\Favorites\[email protected]"
target = glob.glob(targetPattern)
print(target)

filename = r'\test.geom06.part_voiture'

joiend = [target,filename]
for ready in joiend:
    # JOIN TARGET
    print(''.join(["\".join(target),r'\test.geom06.part_voiture']))

print(ready)


couche_voiture = ready


for i in users:
    arcpy.ChangePrivileges_management(couche_voiture, i, "GRANT", "AS_IS")

    message = "privilege modifié pour " + i + "sur finess"
    print(message)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 definitlynothash