Python - error caused by space in argv Arument

I had a Python program running under Mint that called another: -

repoCmd = 'Purchaser.py task ' + repoTask + ' "' + LastDataPath +'"' os.system(repoCmd) 

The quotation marks around LastDataPath were needed because some directory names had spaces โ€” usually the Christianโ€™s first and last name. The problem was that although the errors of the called program went to the log file, the wx.MessageDialog window was obviously not displayed.

Now I have changed the program so that it does not make a system call:

 SWCore.main(repoCmd) 

However, the problem with spaces in the directory name appeared again: -

 def main(args): orig = sys.argv sys.argv = args.split() 

recognizes a space between quotes. While I could code a typical example, I need a more general solution if there is more than one space, for example. "/ home / user / data / James fforbes Smythe" or "/ home / user / data / XYZ Bank / John Smith"

+1
source share

Source: https://habr.com/ru/post/945234/


All Articles