Skip to content

sg-s/python-paths

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

The sublime beauty of just running your own damn code in python.

One of the most fundamental tasks every programmer has to do at some point is to run some code they wrote from somewhere else. Typically, one writes a helper function, and you want to use it from a different program. In C++ land, this is as simple as #include ing your code, which simply copies and pastes your code. Crude, but easy to understand, and it works.

In the following section I compare how easy it is to do this task in MATLAB and python, two commonly used languages in research computing.

To be clear, the task we want to accomplish is this:

  • We have some code X in location XX (on our local computer)
  • We are working on code Y in location YY (also on our local computer)
  • We want to use X in Y.

MATLAB

This is how you do it in MATLAB:

addpath("/path/to/X/")
% run your code

python

Things are obviously much easier in python, as this highly upvoted answer on StackOverflow illustrates:

1

2

3

But wait! It turns out that none of these is what you really want to do. What you should be doing is using pip install . on X, which involves writing a setup.py file, for which there are these helpful instructions

Phew! python really makes it easy to do this very basic task, so we can focus our attention to more challening tasks, like working with arrays

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors