Perl2Python: Get the current working path



Perl
Cwd can be used to get pathname of current working directory.
  1. use Cwd;
  2. my $dir = getcwd;

To get the current working directory use os.getcwd()
The question asked for the directory of a given file, so the proper answer is:
  1. import os
  2. os.path.dirname(os.path.realpath(__file__))

Comments

Popular posts from this blog

gspread error:gspread.exceptions.SpreadsheetNotFound

Update the TOC (table of content) of MS Word .docx documents with Python

P and q values in RNA Seq