Featured
-
No Featured Found!
Tags
How to create the match Function in python
In python match Function is a function witch attempts to match RE pattern to string with optional flags and re.match function returns a match object on success, None on failure.
Here is the syntax for this function:
re.match(pattern, string, ...
ThetimeModule in python
There is a popular time module available in Python which provides functions for working with times and for converting between representations. Here is the list of all available methods
1-time.altzone
The offset of the local DST ti...
How to create class in python
In python class statement creates a new class definition and The class has a documentation string which can be accessed via ClassName.__doc__. The class_suite consists of all the component statements defining class members, data attributes and fu...
How to Getting calendar for a month in python ?
If you want to getting calendar for a month then we can set calendar module as it gives a wide range of methods to play with yearly and monthly calendars. Here, we print a calendar for a given month ( Jan 2008 ) and for example you can see below...
How to Getting formatted time in python ?
If you want to getting formatted time then we can format any time as per your requirement, but simple method to get time in readable format is asctime() and for example you can see below code
#!/shiva/bin/python
import time;
localtime = time...
How to getting current time in python ?
If you want to getting current time instant from a seconds since the epoch floating-point value into a time-tuple, pass the floating-point value to a function .For example you can see below code.
#!/siva/bin/python
import time;
loc...
What is TimeTuple in python ?
In Python time functions handle time as a tuple of 9 numbers, given below example
0
4-digit year
2008
1
Month
1 to 12
2
Day
1 to 31
3
Hour
0 to 23
4
Minute
0 to 59
5
Second
0 to 61 (60 or 61 are leap-seconds)
6
Day of Week
...
What is Tick in python ?
The floating-point numbers in units of seconds for time interval are indicated by Tick in python.
Particular instants in time are expressed in seconds since 12:00am, January 1, 1970(epoch). And there is a popular time module available...
Multithreaded Priority Queue in Python
With the help of Queue module we can create a new queue object that can hold a specific number of items and threads. Queue module have following method which is given below.
get(): The get() removes and returns an item from the queue.
put(): Th...
Synchronizing Threads in Python
With the help of threading module we can implement locking mechanism that allows you to synchronize threads. And a new lock is created by calling the Lock() method, which returns the new lock and thread in threads module.
For example you can see...
How to handle Simple Mail Transfer Protocol (SMTP) in python
In python Simple Mail Transfer Protocol (SMTP) is a protocol. Python provide smtplib module to handle the email system and SMTP client session object which is used to send mail to any Internet machine with an SMTP or ESMTP listener daemon along w...
Creating Thread Using Threading Module in Python
If you want to implement a new thread using the threading module, you have to follow the following steps which is given below
Step-1 Define a new subclass of the Thread class.
Step-2 Override the __init__(self [,args]) method to add additional ...
Passing Information Using POST Method in Python
We pass information to a CGI program in the POST method. And post packages give the information in exactly the same way as GET methods but instead of sending it as a text string after using post. In the URL it sends it as a separate message. This...
How to use the dis Module in python
In python dis module converts byte codes to a format and You can run the disassembler from the command line and It compiles the given script and prints the disassembled byte codes to the stdout . The dis function takes a class, method, function o...
How to create tuples in python?
In python, tuples is just like a list but little differ form list, To say correctly tuples is a sequence of immutable Python objects and it can not be change just like a list also tuples use parentheses.
Creating a tuple is as simple you have to...
what is loop control statements in python
In python loop control statements means(CSM) that CSM is change execution from its normal sequence and When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
python support three statements of loop co...
How to create for loop in python?
In python to create for loop refers to executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
Use the below example to create for loop:
test = raw_input("what is for loop ")
for letter i...
Accessing Values in Strings in python
Python does not support a character type treated as strings of length 1, thus also consider a substring.
To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring. For example
#!/usr/b...
The tabnanny Module in python
tabnanny module helps us to check Python source files for
With the help of tabnanny module we can checks Python source files for unclear indentation. If a tabs and spaces are mixed by a file in such a way that throws off indentation, no matte...
The profile Module in python
The profile module is a standard Python profiler. And with the help of profile module we can run the profiler from the command line. For example you can see the below code.
#!/usr/bin/python
vara = 17
varb = 400
sum = vara + varb
print "va...
The pdb module in python
The pdb module stand for Python debugger. It is used on the bdb debugger framework.
And we can run the debugger from the command line and go to the next line and help to get a list of available commands.For example you can see below code.
$p...
DisModule in Python
Dis module is the Python disassembler. It is used to converts byte codes to a format that is slightly more appropriate for human consumption and python function.
And we can run the disassembler from the command line. It can use to compiles the g...
Global and Local variables in Python
Python Variables that are defined inside a function body have a local scope, and those defined outside have a global scope and variable.
That indicate local variables can be accessed only inside the function in which they are declared, whereas g...
ThereturnStatement in Python
In return statement return exits a function, optionally passing back an expression to the caller and value. A return statement with no arguments is as same as return None and function. For example you can see below example for return statement.
...
Scope of Variables in Python
In Python variables in a program which may not be accessible at all locations in python program. This depends on where you have declared a variable and value.
The scope of a variable determines the portion of the program using which we can acces...
The return Statement in Python
The return statement indicate that return exits in a function and optionally pass back an expression to the caller variable and return statement with no arguments is the same as return None variable.
For example you can see below code and try it...
Function Arguments in Python
In python function use the following types of formal arguments which is given below
Required arguments-> Required arguments are the arguments passed to a function in correct positional order and the number of arguments used in the function ca...
Calling Function in Python
A function gives name, specifies the parameters which are included in the function and structures have to be included in the blocks of code and function.
And the basic structure of a function is finalized, we can execute it by calling it from an...
How to Get Print in Python
print : It produces text output on the console.
Syntax:
print "Message"
print Expression
To print the given text message or expression value on the console, you have to moves the cursor down to the next line.
print Item1, Ite...
Variable in Python
variable: A named piece of memory that can store a value.
Usage:
Compute an expression result,
store that result into a variable,
and use that variable later in the program.
assignment statement: Stores a value into a variable.
Syntax:
...
Programming basics in Python
code or source code: The sequence of instructions in a program.
syntax: The set of legal structures and commands that can be used in a particular programming language.
output: The messages printed to the user by a program.
console: The t...
Combining try, except and finally in Python
An error that occurs during the execution of a computer program is known as exception.
Exceptions are known to non-programmers as instances that do not conform to a general rule.
The code, which harbours or blink the risk of an exception, is fi...
Exception Handling in Python
An exception is an error that happens during the execution of a program. Exceptions are known to non-programmers as instances that do not conform to a general rule.
The code, which harbours the risk of an exception, is embedded in a try block
L...
Statically and dynamically language in Python
statically typed language:
A language in which types are fixed at compile time. Most statically typed languages enforce this by requiring you to declare all variables with their data types before using them. Java and C are statically typed langu...
Quotation in Python
The quotes single ('), double (") and triple (''' or """) is used to denotes string literals are accepted by python but the same quotes should starts and ends the string.
Triple quotes signify a multi-line string. Everything between the start ...
Python Identifiers and Lines and Indentation
Identifier is a name used to identify a variable,function, class, module or other object.Python does not allow punctuation characters such as @, $ and % within identifiers. Python is a case sensitive programming language.
Lines and Indentation: ...
Python Official Website and install python
Python Official Website : http://www.python.org/"
Python Documentation Website : www.python.org/doc
Python binary can be found here:
https://www.python.org/downloads/
Python IDEs:
http://sourceforge.net/projects/pyscripter/
https://win...
Internet Scripting in Python
Python scripts can:
1-Communicate over sockets.
2-Extract form information sent to server-side CGI scripts.
3-Transfer files by FTP.
4-Parse, generate, and analyze XML files.
5-Send, receive, compose, and parse email.
6-Fetch web pages by U...
COMPONENT INTEGRATION IN PYTHON
Python have following integration which is given below:-
1. Python scripts can easily communicate with other application using variety of integration mechanisms.
2. simple object persistence system is provided by Python's standard pickle module...
What is python ?
Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language
Python programs are portable, i.e. they can be ported to other operating systems like Windows, Linux, Unix and Mac OS X, and they can be ru...