regex - before event shutil copy2 -
i want utilize own copy2 function when calling shutil.copytree
. using regex on dst create new dst(copy , rename). see function header copy2 shutil.copy2(src, dst, *, follow_symlinks=true)
. if create following:
def my_copy2(???): homecoming copy2(src, newdst...)
what should function header like, , phone call copy2
with? uncertain happens empty *
, symlink argument, i.e. care?
this works, not same function signature copy2:
#!/usr/bin/python import shutil def copy_and_rename(src,dst) : homecoming shutil.copy2(src, dst.replace("pdf","zzz")) src_dir="srcjunk" dest_dir="destjunk" shutil.copytree(src_dir, dest_dir, copy_function=copy_and_rename)
you can import module within function or can on script. documentation doesn't explain *
. omit it.
from shutil import copy2 def my_copy2(src, newdst, ...) homecoming copy2(src, newdst, ...)
or import within (also import shutil
, import shutil.copy2
):
def my_copy2(src, newdst, ...) shutil import copy2 homecoming copy2(src, newdst, ...)
you must give plenty parameters function copy2
able run. abut using regex means before using string prepare it, adding suffix, or adding path want store it. can done within function or outside.
regex python-3.x directory
No comments:
Post a Comment