Reputation: 438
Hello i'm trying to simply copy a directory to another directory on the same windows machine. This code runs without any errors but I got to the directory and it never copied it. Here is my code. Any ideas?
import File
from distutils.dir_util import copy_tree
if __name__ == "__main__":
sourceFolder = File.File
targetFolder = File.File
sourceFolder.filePath = 'C:\\Workspace\\PythonAutomation\\1-DEV\\PythonAutomation'
targetFolder.filePath = 'C:\\Workspace\\PythonAutomation\\2-QA'
copy_tree(sourceFolder.filePath, targetFolder.filePath)
Edit: note that the content in the dir is python scripts and a Visual studio Solution. Could that be the issue? Is there only certain file types that the copy_tree can copy?
Upvotes: 0
Views: 85
Reputation: 26717
Here's basically what's going on. Because you gave a single, mutable object (I'm guessing it's a class definition, but it doesn't have to be) multiple names, changing it via one name changes it via all names.
class File:
class File:
pass
spam = File.File
eggs = File.File
# spam and eggs refer to the *exact same thing*
assert spam is eggs
# we can lazily create a "cheese" attribute inside it
spam.cheese = 'leicester'
# but because spam and eggs are identical, this overwrites it
eggs.cheese = 'stilton'
assert spam.cheese == eggs.cheese
assert spam.cheese is eggs.cheese
This is functionally identical to the simple case:
spam = {'a': 1}
eggs = spam
eggs['a'] = 2
assert spam['a'] != 2 # fails
Upvotes: 1