function - Analagous operations to achieve os.path.split in Python? -


i have been using automator on osx [according previous questions] , my os.path.split not working reason though same code runs fine in coderunner , terminal...

is there other way achieve function:

import os input = '/users/opus_magnum/desktop/list.txt' output = 'test_output.txt'  dir,file = os.path.split(input) temp_out= os.path.join(dir,output) out_file=open(temp_out,'w')  print dir print file print temp_out  >> /users/opus_magnum/desktop >> list.txt >> /users/opus_magnum/desktop/test_output.txt 

i'm trying create new file in same directory input file

i prefer know causing os.path.split function not work if analogous available guess can work .

you can use os.path.dirname() obtain directory of input file.

input = '/users/opus_magnum/desktop/list.txt' input_dir = os.path.dirname(input) output = 'test_output.txt' temp_out = os.path.join(input_dir, output) 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -