<commit_before># how to use os module

## file operation

### check existence of file or path

```
os.path.exists(path)
```

### delete file/directory

	os.remove()
	os.rmdir()
	shutil.rmtree()

### implementation of touch

	def touch(fname, times=None):
		with open(fname, 'a'):
			os.utime(fname, times)<commit_msg>Update programming-language/python/os.md<commit_after># how to use os module

## file operation

### check existence of file or path

```
os.path.exists(path)
```

### delete file/directory

	os.remove()
	os.rmdir()
	shutil.rmtree()

### implementation of touch

	def touch(fname, times=None):
		with open(fname, 'a'):
			os.utime(fname, times)

### change permission bits

```
import os
import stat

st = os.stat('somefile')
os.chmod('somefile', st.st_mode | stat.S_IEXEC)
```

https://stackoverflow.com/questions/12791997/how-do-you-do-a-simple-chmod-x-from-within-python
{'fraction_non_alphanumeric': 0.16292134831460675, 'fraction_numerical': 0.008988764044943821, 'mean_word_length': 4.367469879518072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1536492', 'n_tokens_mistral': 342, 'n_tokens_neox': 317, 'n_words': 75}