Create a file using the touch command in Mac or Unix-like OS
Create a file using the touch command in Mac or Unix-like OS Home / problem You are playing with something cool on your machine and all of the sudden you wish to create an empty file for testing purposes. For example, a classic case, a text file that will be manipulated by a program. SOLUTION […]
How to delete a file in Python
How to delete a file in Python Home / problem You wish to delete one or more files with Python. In this post we will see how to do that using the os library. SOLUTION We import the os library that gives us functions from the Operating System. More specifically, deleting a file is an […]
How to get File System’s separator using Python
How to get FileSystem’s separator using Python Home / problem You’re writing a program (e.g. AWS lambda) in Python that is using a file path and runs on various Operating Systems. For example, Windows OS uses a different separator in comparison with Mac OS. Operating System File Path example Windows C:DocumentsNewslettersSummer2018.pdf Mac OS /home/user/documents SOLUTION […]
How to add a video in HTML
How to add a video in HTML Home / problem You’re learning HTML and wish to place a video item on your page. In this post we will see how to load and play a video from a local video file and remotely via a URL. SOLUTION Using the <video> tag. It has an opening […]
Writing to a file in Python
Writing to a file in Python Home / problem In a program, the data are stored in memory (RAM) and are volatile. In this post we will see how to save (persist) some data so the program can later load them. The data will be stored in a text file. SOLUTION In Python, we can […]
Read a file in Python
Read a file in Python Home / problem You’re learning Python and wish to use the file system in your program. With files we can retrieve information from our machine, load it in our program and manipulate it as we like. With a file we can persist data. SOLUTION Let’s suppose we have the following […]