This will print 5. In this it will only assign a defaule value for one time.
def car(wheels,modle="toyota"):
print "No of wheels",wheels
print "Modle name : ",modle

car(4,modle="dimo")

More list methods
a=[2,333,333,45.4,] We will use this list for the following samples.
print a.count(333),a.count(2),a.count(99)
2 1 0
-
a.append(x)
this will add x to the end of "a" list.
-
a.extend(list)
add another list to list 'a'.
-
a.insert(index,value)
this will add a value to a given index.
-
a.remove(x)
this will remove the first x value.
-
a.pop()
this will remove & return the last value in the list
if it is like this;
a.pop(3)
it will remove the 4th value and return that value.
-
a.index(333)
this will give the index of the first 333 value in the array.
-
a.sort()
this will sort the array
-
a.reverse()
this will revers te array

Return value of a program
Try this
#!/bin/bash
cd dada/ &> /dev/null/
echo return value : $?
cd &> /dev/null/
echo return value : $?
In ths program it will give a value as
1
0
If there is an error it will return 1 & if there is no error it will return value 0.
By this values we can make our program more user friendly.

sed
$sed 's/to_be_replace/replaced/g' /file_path
eg :
$sed /s/name/Name/g' ~/user_details.t
This will read the "user_details.t" file in my home directory and it will replace the "name" keyword to "Name" and give the output on stdout.

Aug 27, 2010

Python is an interpreted programming language. By just tuping python you can start programming.
When you type,
$python
It willl display as;
>>>
here you can type your program.
To exit from it, you can type Crlt+d or quit().

# is used to comment

Interpreter can be used as a calculator.
>>> (25+5)/5
6

The equal sign in used to assign values to a variable
>>>a=100 # assign 100 to a
>>>b=2*5 # assign 2*5 (10) to b
>>>a+b
110

complplex numbers are also supported, like
>>>complex(3,5)+complex(5,-5)
10+0j

In the interactive mode, the last printed output is asigned to the _ variable. So you can use,
>>>100+50
>>> _/3 # this work as 150/3
50
to forword last output to some other task.

Strings in python
>>>word="hello \n world"
>>>print word
hello
world

If you are deviding the string in to two parts you should use a \ like
>>>word="hello \
...world"
>>>echo word
hello world

Aug 26, 2010

Auto save
In emacs ther is a recovery mechanisum which is usefull if the system crashes while editing something.
When you need to recover something; it was saved in a format of "#file_name#". So you only need to open this file. But note if you save a file, this #file# will deleted by the emacs.

Mode line
--:** TUTORIAL 63% L749 (TEXT)------------------

63% :- indicates the current position of the document.
** :- indicates that you have edit the document
L749:- indicates the line number of the point
(TEXT):-_give an idea of the mode that you'r editing

Search
Emacs can search for strings. To search;
Ctrl + s
this will pormpt to input characters you need to search. While you are typing it will highlight the words.
By pressing Ctrl+s again and again you can switch between highlighted words.

If you need to compress a text document you can use;
$gzip textfile.txt
This will convert the txt file to "textfile.gz".
To view a gz file you can use; $zcat

To view diffes between two files we can use;
$diff file1 file2 - in the output of this command < will view the diffes in file1 &
> will view the diffes in file2

$find . -name "*.txt" -print ;
This command will find for the file name with ".txt" and print the file path. And also note the "." after the command. It meens the find is running on current directory and in all other sub-directories.

Compiling source code

First create a directory in homedirectory to store the program. Use mkdir command for it.

Then go inside the directory and type;
$./configure -prefix=$HOME/file_name
It will set the instalation path to your destination.
Now type;
$make
This will make the excecutable files
After that we should check the excecutable is working properly. To do that;
$make check
Then,
$make install - to install the program.
Now type;
$./"your_command_name"
It will run the program.
(* Note:- if you need to run the program by only typing the program name, you mustadd the path of the program to the PATH variable.
$set path=($path ~/directory/bin)
)

Variables
Variables are a kind ofpassing information from the shell to programs when there are running.
There are two types of variables,
1. Environment variables (in UPPER CASE)
2. Shell variables (in lower case)
By using $env command you can view environment variabler with their values.
USER, HOME, PATH and HOST are some environment variables.

If you need to compress a text document you can use;
$gzip textfile.txt
This will convert the txt file to "textfile.gz".
To view a gz file you can use; $zcat

To view diffes between two files we can use;
$diff file1 file2 - in the output of this command < will view the diffes in file1 &
> will view the diffes in file2

$find . -name "*.txt" -print ;
This command will find for the file name with ".txt" and print the file path. And also note the "." after the command. It meens the find is running on current directory and in all other sub-directories.

Compiling source code

First create a directory in homedirectory to store the program. Use mkdir command for it.

Then go inside the directory and type;
$./configure -prefix=$HOME/file_name
It will set the instalation path to your destination.
Now type;
$make
This will make the excecutable files
After that we should check the excecutable is working properly. To do that;
$make check
Then,
$make install - to install the program.
Now type;
$./"your_command_name"
It will run the program.

Now you can merg them together by;
$git merg "name"
If there is no conflict you are done.If there are, it will be left in problematic files showing the conflicts.
$git branch -d "name" will ensure that the changers in the "name" branch are already in the current branch.

It will initialized the project and creats a .git file in the working directory.
Next tell git to create a snapshot of the content of each document inside the working directory.
$git add . {note the .}

Unix is an operating system which was first developed in 1960. It is astable, multitasking, multiuser operating system for all laptops, desktops and servers.
There are three parts of an UNIX operating system.
1. Kernel - The hub of the os. It manage time and memory. Handle file storage and communication.
2. Shell - It works as a inteface between user and the system.
3. Programs

Basic commands

ls - list the content in a directory
(type "man ls" to get more details about ls command)

Aug 24, 2010

Emacs is a basic GNU Emacs is an extensible, customizable text editor--and more. At its core is an interpreter for Emacs Lisp, a dialect of theLisp programming language with extensions to support text editing.