This can be done as a single expression, that is, without the need to use semicolons:
__import__('shutil').copy(__import__('sys').argv[1], __import__('sys').argv[2])
or
open(__import__('sys').argv[2], "w").write(open(__import__('sys').argv[1]).read())
Of course, no one in their right mind would prefer this to your sample code. The only change I would make is that there is no reason to assign file names to temporary variables:
from sys import argv open(argv[1],'w').write(open(argv[2]).read())
More pythonic way of writing:
import sys with open(sys.argv[1]) as src, open(sys.argv[2]) as dest: for line in src: dest.write(line)
and then you can start using argparse to make command line reading more reliable ...
source share