Hi suppose in python I have a list(or array, or tuple, not sure the difference)
How do I loop inside the size of array.
The pseudo code is:
a=
for i = 1 to dim(a)
print a
end
How to find the dimension in python?
Also, anyone has a handbook to suggest so I can borrow from library (1 Reply)
Hi All,
I want to pass few dynamic arguments to shell script. The number of arguments differ each time I call the script.
I want to print the arguments using the for loop as below. But not working out.
for (( i=1; i<=$#; i++ ))
do
echo $"($i)"
done
/bin/sh test.sh arg1 arg2 arg3
... (1 Reply)
Hi,
I am trying to run a python script embedded in bash script. But is throwing me an error. Please help.
Script:
#!/bin/bash
nohup /usr/bin/python /opt/web/http.py &
Error:
/usr/bin/python: can't open file '/opt/web/http.py': No such file or directory
Please help me on this. (6 Replies)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk... (2 Replies)
How do i pass an array from test4.sh to a function in another shell script test5.sh, basically i am sourcing the test5.sh in test4.sh and printing the contents, but not working below are my trial scripts, please help, thank you.
#!/bin/bash
# /usr/local/dw/archive/test5.sh
print_array()
{... (5 Replies)
Hi All,
I need to get the version of python installed and store it in a variable for later use. Whereas it is printing on the console instead of storing to variable. I am able to store output of ls command in a variable. Please check the below code :
root@myhost:/volumes/srini# cat... (4 Replies)
I am working on requirement on spreadsheet in python scripting.
I have a spreadsheet containing cell values and with background color.
I am able to read the value value but unable to get the background color of that particular cell.
Actually my requirement is to read the cell value along... (1 Reply)
I'm trying to achieve the follwoinig with no luck.
Find the directories that are greater than 50GB in size and pick the owner of the directory as I would like to send an alert notification.
du -sh * | sort -rh
139G Dir_1
84G Dir_2
15G Dir_3
ls -l Dir_1
drwx------ 2... (3 Replies)
I am trying to loop through lots and lots of folders and use the names of the folders to run a Python script which has parameters.
E.g.
-- setup_refs -n John -f England/London/Hackney/John -c con/con.cnf
Normally to run `setup_refs` once from command line it's: `python setup_refs.py -n John... (3 Replies)
Discussion started by: Mr_Keystrokes
3 Replies
LEARN ABOUT OSX
pythonw
PYTHON(1) BSD General Commands Manual PYTHON(1)NAME
python, pythonw -- an interpreted, interactive, object-oriented programming language
SYNOPSIS
python ...
pythonw ...
DESCRIPTION
To support multiple versions, the programs named python and pythonw now just select the real version of Python to run, depending on various
settings. (As of Python 2.5, python and pythonw are interchangeable; both execute Python in the context of an application bundle, which
means they have access to the Graphical User Interface; thus both can, when properly programmed, display windows, dialogs, etc.) The current
supported versions are 2.6 and 2.7, with the default being 2.6. Use
% man python2.6
% man python2.7
% man pythonw2.6
% man pythonw2.7
to see the man page for a specific version. Without a version specified,
% man pydoc
and the like, will show the man page for the (unmodified) default version of Python (2.6). To see the man page for a specific version, use,
for example,
% man pydoc2.7
CHANGING THE DEFAULT PYTHON
Using
% defaults write com.apple.versioner.python Version 2.7
will make version 2.7 the user default when running the both the python and pythonw commands (versioner is the internal name of the version-
selection software used).
To set a system-wide default, replace 'com.apple.versioner.python' with '/Library/Preferences/com.apple.versioner.python' (admin privileges
will be required).
The environment variable VERSIONER_PYTHON_VERSION can also be used to set the python and pythonw version:
% export VERSIONER_PYTHON_VERSION=2.7 # Bourne-like shells
or
% setenv VERSIONER_PYTHON_VERSION 2.7 # C-like shells
% python ...
This environment variable takes precedence over the preference file settings.
64-BIT SUPPORT
Versions 2.6 and 2.7 support 64-bit execution (which is on by default).
Like the version of Python, the python command can select between 32 and 64-bit execution (when both are available). Use:
% defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
to make 32-bit execution the user default (using '/Library/Preferences/com.apple.versioner.python' will set the system-wide default). The
environment variable VERSIONER_PYTHON_PREFER_32_BIT can also be used (has precedence over the preference file):
% export VERSIONER_PYTHON_PREFER_32_BIT=yes # Bourne-like shells
or
% setenv VERSIONER_PYTHON_PREFER_32_BIT yes # C-like shells
Again, the preference setting and environmental variable applies to both python and pythonw.
USING A SPECIFIC VERSION
Rather than using the python command, one can use a specific version directly. For example, running python2.7 from the command line will run
the 2.7 version of Python, independent of what the default version of Python is.
One can use a specific version of Python on the #! line of a script, but that may have portability and future compatibility issues.
Note that the preference files and environment variable that apply to the python command, do not apply when running a specific version of
Python. In particular, running python2.6 will always default to 64-bit execution (unless one uses the arch(1) command to specifically select
a 32-bit architecture).
SEE ALSO python2.6(1), python2.7(1), pythonw2.6(1), pythonw2.7(1), arch(1)BSD Aug 10, 2008 BSD