Reputation: 1277
I'm trying to copy files to a new directory using python, and to do so, I set up two os variables $path1 and $path2 as follows:
os.environ['path1'] = '<filename>'
os.environ['path2'] = '<dirname/filename2>'
os.system['cp $path1 $path2']
This gives me "builtin_function_mor_method' object has no attribute 'getitem' each time. I've seen almost identical syntax online and have used it, so I can't figure out what I'm doing wrong.
Upvotes: 0
Views: 333
Reputation: 20351
You are calling the function incorrectly:
os.system('cp $path1 $path2')
That is, you want ()
, not []
. []
is for getting items from an iterable, ()
is for calling a function like in your case.
Upvotes: 2