You're not calling the function user_input
(by using ()
). (fixed in question by OP).
Also, you need to return a string from user_input
. currently you're trying to set a variable f1
which is local to the function user_input
. While this is possible using global
- I do not recommend this (this beats keeping your code DRY).
It's possible to do something similar with objects by changing their states. String is an object - but since strings are immutable, and you can't have the function change their state - this approach of expecting a function to change the string it's given is also doomed to fail.
def user_input():
return raw_input("Enter the source file :").strip()
copy_file(user_input(),user_input())
You can see user_input
does very little, it's actually redundant if you assume user input is valid.