I'm making a simple function to send mails with mutt. Sometimes I'll need to send attachments and sometimes not, so I need to check if the parameter "attachment" have something on it. Right now my code looks like this:
def sendMail(destino,asunto,cuerpo,adjunto):
try:
os.system('echo "' + cuerpo + '" | mutt -s "' + asunto + '" ' + destino)
How whould be the proper way of checking if "adjunto" (attachment variable) contains something and add "-a adjunto" to the command only if there's an attachment? I know I could do a regular "if" statement and use a different os.system if I have some attachment, but I want to know if there's any way of doing that check inline. Something like "..... asunto + '" ' + destino (('+ ' + adjunto) if adjunto=true)"
PS: I know the code is still not finished, but I want to know how to efficiently check for attachments.