Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6244347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:18:38+00:00 2026-05-24T12:18:38+00:00

I am relatively new to python. I am trying to copy a directory to

  • 0

I am relatively new to python. I am trying to copy a directory to another directory maintaining the structure.

I am using

    shutil.copytree(src, dst, symlinks=False, ignore=None, 
    copy_function=copy2, ignore_dangling_symlinks=False)

I am trying to write a call back function for ignore.

My aim is to take a list of files in a list , and copy only those files,ignoring the rest. How do we pass a list into the call back function?

I wrote a simple call back function , but I get some error when I try to run the copyTree function

   def abc(src,names):
    print(src)
    print(names)



    Traceback (most recent call last):
   File "<pyshell#23>", line 1, in <module>
shutil.copytree('D:\Mytest','D:\PythonTestDest3',symlinks=False,ignore=abc)
  File "C:\Python32\lib\shutil.py", line 204, in copytree
if name in ignored_names:
  TypeError: argument of type 'NoneType' is not iterable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:18:39+00:00Added an answer on May 24, 2026 at 12:18 pm

    The return of the ignore function needs to be a list of directories and files to ignore. You aren’t returning anything, which returns None, so you are getting the error TypeError: argument of type 'NoneType' is not iterable.

    Here’s an example that will copy the folder structure and the files listed in ‘copy_these’:

    import os.path
    
    copy_these = ['a.txt', 'b.txt', 'c.txt']
    
    def ignore_most(folder, files):
    
        ignore_list = []
        for file in files:
           full_path = os.path.join(folder, file)
           if not os.path.isdir(full_path):
               if file not in copy_these:
                   ignore_list.append(file)
        return ignore_list
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still relatively new to python, 1-2 years of solo-learning, and am trying to
I'm relatively new to Python and am having problems programming with Scapy, the Python
I am relatively new to python and app engine, and I just finished my
I'm relatively new to the Python world, but this seems very straight forward. Google
I'm a relatively new convert to Python. I've written some code to grab/graph data
I'm relatively new to wxPython (but not Python itself), so forgive me if I've
Relatively new to rails and trying to model a very simple family tree with
I am relatively new to Python, and I am experimenting with writing the following
I am relatively new to Python and was hoping someone could explain the following
I am relatively new to C++ (previous experience in Python and dabbled in Java)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.