[Tutor] How to call the path of an input file

Martin A. Brown martin at linux-ip.net
Thu Jan 21 12:12:29 EST 2016


Greetings John,

>I would like to know what is the syntax to call the path of the 
>input file. Below, my code is calling the input file, but not the 
>path.

>import sys
>path = sys.argv[1]

Are you looking for os.path.abspath() [0]?

  import os
  import sys
  path = os.path.abspath(sys.argv[1])

>y = map(str.lower, path.split())

Next question:  What exactly are you trying to do with that third 
line?  It looks confused.

Good luck,

-Martin

 [0] https://docs.python.org/3/library/os.path.html#os.path.abspath

-- 
Martin A. Brown
http://linux-ip.net/


More information about the Tutor mailing list