Thursday, May 14, 2026
HomeLanguagesPython | shutil.unregister_unpack_format() method

Python | shutil.unregister_unpack_format() method

Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating process of copying and removal of files and directories.

shutil.unregister_unpack_format() method in Python is used to unregister or remove an unpack format from the list of available supported unpack format.

We can also register a new format or specify own function for unpacking existing formats using shutil.register_unpack_format() method or get the list of all supported available unpack format using shutil.get_unpack_formats() method.

Syntax: shutil.unregister_unpack_format(name)

Parameter:
name: A string representing the name of the unpack format which is to be removed from the list.

Return Type: This method does not return any value.

Code: Use of shutil.unregister_unpack_format() method




# Python program to explain shutil.unregister_unpack_format() method  
    
# importing shutil module 
import shutil
  
# Get the list of 
# supported unpack formats
formats = shutil.get_unpack_formats()
  
# Print the list
print("Supported unpack formats:")
print(formats, "\n")
  
# Remove an unpack format
name = "gztar"
shutil.unregister_unpack_format(name)
print("%s unpack format unregistered successfully." %name, "\n")
  
# Get the list of 
# supported unpack formats
formats = shutil.get_unpack_formats()
  
# Print the list
print("Supported unpack formats:")
print(formats, "\n")


Output:

Supported unpack formats:
[(‘bztar’, [‘.tar.bz2’, ‘.tbz2’], “bzip2’ed tar-file”), (‘gztar’, [‘.tar.gz’, ‘.tgz’], “gzip’ed tar-file”), (‘tar’, [‘.tar’], ‘uncompressed tar file’), (‘xztar’, [‘.tar.xz’, ‘.txz’], “xz’ed tar-file”), (‘zip’, [‘.zip’], ‘ZIP file’)]

‘gztar’ unpack format unregistered successfully.

Supported unpack formats:
[(‘bztar’, [‘.tar.bz2’, ‘.tbz2’], “bzip2’ed tar-file”), (‘tar’, [‘.tar’], ‘uncompressed tar file’), (‘xztar’, [‘.tar.xz’, ‘.txz’], “xz’ed tar-file”), (‘zip’, [‘.zip’], ‘ZIP file’)]

Reference: https://docs.python.org/3/library/shutil.html

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS