How to delete a file or folder in Python?

os.remove() removes a file. os.rmdir() removes an empty directory. shutil.rmtree() deletes a directory and all its contents. Path objects from the Python 3.4+ pathlib module also expose these instance methods: pathlib.Path.unlink() removes a file or symbolic link. pathlib.Path.rmdir() removes an empty directory.

How to uninstall pip on OSX?

The first thing you should try is: On many environments that doesn’t work. So given the lack of info on that problem, I ended up removing pip manually from /usr/local/bin.

How to read a large file – line by line?

The correct, fully Pythonic way to read a file is the following: The with statement handles opening and closing the file, including if an exception is raised in the inner block. The for line in f treats the file object f as an iterable, which automatically uses buffered I/O and memory management so you don’t … Read more

What does the “yield” keyword do?

To understand what yield does, you must understand what generators are. And before you can understand generators, you must understand iterables. Iterables When you create a list, you can read its items one by one. Reading its items one by one is called iteration: mylist is an iterable. When you use a list comprehension, you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)