Advanced

How to Check if a File or Directory Exists in Python

Posted by linuxize on · Post a comment
linuxize.com; By linuxize
Mail this story
Print this story

When writing Python scripts, you may want to perform a certain action only if a file or directory exists or not. For example, you may want to read or write data to a configuration file or to create the file only if it already doesn't exist.

In Python, there are many different ways to check whether a file exists and determine the type of the file.

In this tutorial, we’ll show you three different techniques about how to check for a file's existence.

Full Story

  Nav
» Read more about: Groups: Python

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments

No comments yet. Be the first.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post