python: get directory two levels up

You can use pathlib. Unfortunately this is only available in the stdlib for Python 3.4. If you have an older version you’ll have to install a copy from PyPI here. This should be easy to do using pip. from pathlib import Path p = Path(__file__).parents[1] print(p) # /absolute/path/to/two/levels/up This uses the parents sequence which provides … Read more

mkdir if not exists using golang

Okay I figured it out thanks to this question/answer import( “os” “path/filepath” ) newpath := filepath.Join(“.”, “public”) err := os.MkdirAll(newpath, os.ModePerm) // TODO: handle error Relevant Go doc for MkdirAll: MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. … If path is already a … Read more

Difference between mkdir() and mkdirs() in java for java.io.File [closed]

mkdirs() also creates parent directories in the path this File represents. javadocs for mkdirs(): Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories. javadocs for mkdir(): Creates the directory named by … Read more

Is it possible to use “/” in a filename?

The answer is that you can’t, unless your filesystem has a bug. Here’s why: There is a system call for renaming your file defined in fs/namei.c called renameat: SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname) When the system call gets invoked, it does a path lookup (do_path_lookup) … Read more

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