Skip to content

Parsing a string as a Python argument list

Summary I would like to parse a string that represents a Python argument list into a form that I can forward to a function call. Detailed version I am building an application in which I would like to be able to parse out argument lists from a text string that would then be converted into the *args,**kwargs pa…

Nested lambda statements when sorting lists

I wish to sort the below list first by the number, then by the text. Attempt 1 I was not happy with this since it required splitting a string twice, to extract the relevant components. Attempt 2 I came up with the below solution. But I am hoping there is a more succinct solution via Pythonic lambda statements…