An easier way to extract role as an uncluttered string

i just want a bloody string.

userRoles = []
for role in self.session.props.auth.user.roles:
	userRoles.append(str(role))
message = str(value) + ' -> ' + str(userRoles)
return message  #<-- yields:  Ian -> ['Read/Write', 'canEdit']
                #  i want JUST:  Ian -> Read/Write, canEdit

i seem to recall there is a simpler way to do this with some Java call, but i'm not a Java dude (yet). tired of having to do these dopey convolutions just to get a clean result. halp!

Why not use python's .join() method?

2 Likes

If you don't want a list then don't create a list???

return "{} -> {}".format(value, ','.join(self.session.props.auth.user.roles)
3 Likes

i thought there was a simpler way using some system.user.doSomeThing(). i already have used join() to clean it up. i must have just misremembered. thx guys. i'll delete this. no real use.

Sure there is, some other user will come and find it, and will have their question answered before they ask it.

2 Likes

fair enough.