CopyPastor

Detecting plagiarism made easy.

Score: 0.809354949736633; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2019-07-16
by hiro protagonist

Original Post

Original - Posted on 2016-12-14
by hiro protagonist



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Starting from Python 3.5, there is [`pathlib.mkdir`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.mkdir):
from pathlib import Path path = Path(settings.MEDIA_ROOT) nested_path = path / ( PATH_CSS_DB_OUT + x) nested_path.mkdir(parents=True, exist_ok=True)
This recursively creates the directory and does not raise an exception if the directory already exists.
(just as [`os.makedirs`](https://docs.python.org/3/library/os.html?highlight=makedirs#os.makedirs) got an `exist_ok` flag starting from python 3.2 e.g `os.makedirs(path, exist_ok=True)`)
Starting from Python 3.5, [`pathlib.Path.mkdir`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.mkdir) has an `exist_ok` flag:
from pathlib import Path path = Path('/my/directory/filename.txt') path.parent.mkdir(parents=True, exist_ok=True) # path.parent ~ os.path.dirname(path)
This recursively creates the directory and does not raise an exception if the directory already exists.
(just as [`os.makedirs`](https://docs.python.org/3/library/os.html?highlight=makedirs#os.makedirs) got an `exist_ok` flag starting from python 3.2 e.g `os.makedirs(path, exist_ok=True)`)

        
Present in both answers; Present only in the new answer; Present only in the old answer;