I do not understand why a space appears at the end:

import os print(os.path.dirname(os.path.realpath('wsgi.py'))) /home/user/folder/app print(os.path.join(os.path.dirname(os.path.realpath('wsgi.py'))),'/upload/') /home/user/folder/app /upload/ 

and how to avoid it?

  • Problems or a space at the end? - Nick Volynkin

2 answers 2

Bracket is not there. You actually print is called with parameters.

 print('/home/user/folder/app', '/upload/') 

Therefore, a space appears between the output lines. '/upload/' should fall into the os.path.join() parameters.

You:

 print(os.path.join(os.path.dirname(os.path.realpath('wsgi.py'))),'/upload/') 

And should be:

 print(os.path.join(os.path.dirname(os.path.realpath('wsgi.py')),'/upload/')) 

Well and in order not to get confused in brackets and commas it is better to break into separate stages (calculation and conclusion):

 p = os.path.join(os.path.dirname(os.path.realpath('wsgi.py')),'/upload/') print(p) 

    Correctly place brackets:

     print(os.path.join(os.path.dirname(os.path.realpath('wsgi.py')),'upload'))