0

I am converting a program from Matlab code to Python code. I am unsure how to approach this part of the code.

 sort_function = what('sort_natural');    % Find characteristics of the function sort_natural
 sort_functionPath = addpath(sort_function.path)     % Store and add to Matlab path

(sort_natural is a function written to sort folders in natual order)

What are the Python equivalents of 'what' and 'addpath.' I know Python does not work the same as Matlab in regards to a path, but how would I convert these lines into Python.

Matt_1011
  • 11
  • 1
  • Does this answer your question? [How do I list all files of a directory?](https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory) – Klaus D. Nov 17 '20 at 03:34
  • When you translate from, say French to English, you can’t translate word for word, you need to understand the meaning of the sentence and express that meaning in the other language. The same is true for translating from one programming language to another. You need to understand the effect of a function or procedure and write code in the other language that has the same effect. Translating `what` to Python is likely useless here, because Python works so differently with paths to code. – Cris Luengo Nov 17 '20 at 14:18
  • There’s not enough context here to understand what this code does, but I think “sort_natural” is a subdirectory, and this subdirectory is being added to the path, so that functions inside can be called. In Python you can `import` source files by path, so you don’t need something like this at all. – Cris Luengo Nov 17 '20 at 14:20

0 Answers0