Category Archives: examples

Append to array in Python

In Python, lists can be used as arrays, because the language doesn’t have built-in support. An array is one chunk of memory that usually consists of multiple elements, where a list is a list of objects where one element points to another and it doesn’t have to be inside one block of memory.

Continue reading

Delete a file or folder in Python

Python provides the os.remove and os.unlink functions to delete files and os.rmdir and shutil.rmtree to delete directories. Python 3.4+ offers an additional module called pathlib and two functions called unlink (deletes a file or symbolic link) and rmtree (deletes an empty directory).

Continue reading