Sto cercando un modo pulito per combinare le variabili in una singola stringa con un separatore predefinito. Il problema è che a volte alcune di queste variabili non esistono sempre o possono essere impostate su Nessuno. Non posso neanche duplicare la stringa del separatore. Esempio di problema:String join da Iterable contenente stringhe e (NoneType/Undefined)
# This works because I have all strings
str('-').join(('productX', 'deployment-package', '1.2.3.4'))
# 'productX-deployment-package-1.2.3.4'
# But I have more args that might be None/or not exist like and that breaks
str('-').join(('productX', 'deployment-package', '1.2.3.4', idontexist, alsonotexist))
str('-').join(('productX', 'deployment-package', '1.2.3.4', None, None, None))
# If I set the other missing variables to empty strings, I get duplicated joiners
str('-').join(('productX', 'deployment-package', '1.2.3.4', '', '', ''))
# 'productX-deployment-package-1.2.3.4---'
C'è un bel modo pulito per fare questo?
Meglio usare ' '-' join' invece di' str ('-') join' – jamylak