which

Finding the column number of the smallest element in a certain row

冷暖自知 提交于 2019-11-28 11:11:01
问题 Using R Say for example you have a matrix such as the one below. > C<-matrix(c(0,-7,2,8,0,0,3,7,0,3,0,3,0,0,0,0),nrow=4,byrow=TRUE) > C [,1] [,2] [,3] [,4] [1,] 0 -7 2 8 [2,] 0 0 3 7 [3,] 0 3 0 3 [4,] 0 0 0 0 How do you find the column number of the smallest element in a certain row. For example I want to know what column number the smallest element in row 1 is. Therefore the output should just be 2. As the smallest element in row 1 is -7 and that is in column 2. I'm assuming the answer is

In bash, “which” gives an incorrect path - Python versions

你说的曾经没有我的故事 提交于 2019-11-28 09:56:28
Can anyone explain how python 2.6 could be getting run by default on my machine? It looks like python points to 2.7, so it seems like which isn't giving me correct information. ~> python --version Python 2.6.5 ~> which python /opt/local/bin/python ~> /opt/local/bin/python --version Python 2.7.2 ~> ls -l /opt/local/bin/python lrwxr-xr-x 1 root admin 24 12 Oct 16:02 /opt/local/bin/python -> /opt/local/bin/python2.7 When I generate an error, I see what's really getting run. Why could this be? ~> python -error-making-argument Unknown option: -e usage: /Library/Frameworks/Python.framework/Versions

'which' equivalent function in Python

只愿长相守 提交于 2019-11-27 12:16:38
I need to setup environment by running which abc command. Is there a Python equivalent function of the which command? This is my code. cmd = ["which","abc"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE) res = p.stdout.readlines() if len(res) == 0: return False return True Rafael Reiter There is distutils.spawn.find_executable() on Python 2.4+ I know this is an older question, but if you happen to be using Python 3.3+ you can use shutil.which(cmd) . You can find the documentation here . It has the advantage of being in the standard library. An example would be like so: >>> import shutil >>>

In bash, “which” gives an incorrect path - Python versions

十年热恋 提交于 2019-11-27 02:42:48
问题 Can anyone explain how python 2.6 could be getting run by default on my machine? It looks like python points to 2.7, so it seems like which isn't giving me correct information. ~> python --version Python 2.6.5 ~> which python /opt/local/bin/python ~> /opt/local/bin/python --version Python 2.7.2 ~> ls -l /opt/local/bin/python lrwxr-xr-x 1 root admin 24 12 Oct 16:02 /opt/local/bin/python -> /opt/local/bin/python2.7 When I generate an error, I see what's really getting run. Why could this be? ~>

'which' equivalent function in Python

為{幸葍}努か 提交于 2019-11-26 15:57:29
问题 I need to setup environment by running which abc command. Is there a Python equivalent function of the which command? This is my code. cmd = ["which","abc"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE) res = p.stdout.readlines() if len(res) == 0: return False return True 回答1: There is distutils.spawn.find_executable() on Python 2.4+ You will need to do: import distutils.spawn , or do from distutils import spawn If you just do: import distutil , you won't be able to call distutils.spawn