Hi Kamalakar, You can use os.path.join() to join the user input to a base path. Python will take care of unix/windows differentiation and append slashes accordingly.
>>> import os >>> base_path = os.getcwd() >>> base_path '/home/amuneer/workspace/playground' >>> file_name = raw_input("Enter Filename\n") Enter Filename play >>> complete_path = os.path.join(base_path, file_name) >>> complete_path '/home/amuneer/workspace/playground/play' >>> Note:if you are not using python3, use raw_input instead of input. raw_input accepts the values as string and therefore people cannot do nasty things by typing executable code. Regards, Abdul Muneer -- Follow me on Twitter: @abdulmuneer <http://twitter.com/#%21/abdulmuneer> On Thu, Apr 18, 2013 at 6:15 PM, Kamalakar gs <foxrun2...@gmail.com> wrote: > HI all, > I have a query that i have doc which is read through python.But instead of > giving path and filename > in the coding.I want to manipulate it like "python has to ask USER for a > specific filename so that python recognizes the directory internally and > read the file ".How do i do this.I have tried with > filename = input ("filename") but it just file name and will not recognises > the path. > > For example: > > file name = input ("file name: ") > > file name = python > > it has to recognizes the path like "C:\users\desktop\python" > > > Thanks > Regards > Kamalakar > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > http://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers