
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

3K+ Views
Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps −Import the Tkinter module.Create the GUI application main window.Add one or more of the above-mentioned widgets to the GUI application.Enter the main event loop to take action against each event triggered by the user.Example#!/usr/bin/python import Tkinter top = Tkinter.Tk() # Code to add widgets will go here... top.mainloop()This would ... Read More

2K+ Views
The Document Object Model ("DOM") is a cross-language API from the World Wide Web Consortium (W3C) for accessing and modifying XML documents.The DOM is extremely useful for random-access applications. SAX only allows you a view of one bit of the document at a time. If you are looking at one SAX element, you have no access to another.Here is the easiest way to quickly load an XML document and to create a minidom object using the xml.dom module. The minidom object provides a simple parser method that quickly creates a DOM tree from the XML file.The sample phrase calls the ... Read More

8K+ Views
SAX is a standard interface for event-driven XML parsing. Parsing XML with SAX generally requires you to create your own ContentHandler by subclassing xml.sax.ContentHandler.Your ContentHandler handles the particular tags and attributes of your flavor(s) of XML. A ContentHandler object provides methods to handle various parsing events. Its owning parser calls ContentHandler methods as it parses the XML file.The methods startDocument and endDocument are called at the start and the end of the XML file. The method characters(text) is passed character data of the XML file via the parameter text.The ContentHandler is called at the start and end of each element. If the parser is not in namespace mode, ... Read More

1K+ Views
The Queue module allows you to create a new queue object that can hold a specific number of items. There are following methods to control the Queue −get() − The get() removes and returns an item from the queue.put() − The put adds item to a queue.qsize() − The qsize() returns the number of items that are currently in the queue.empty() − The empty( ) returns True if queue is empty; otherwise, False.full() − the full() returns True if queue is full; otherwise, False.Example#!/usr/bin/python import Queue import threading import time exitFlag = 0 class myThread (threading.Thread): def __init__(self, threadID, name, q): ... Read More

11K+ Views
The threading module provided with Python includes a simple-to-implement locking mechanism that allows you to synchronize threads. A new lock is created by calling the Lock() method, which returns the new lock.The acquire(blocking) method of the new lock object is used to force threads to run synchronously. The optional blocking parameter enables you to control whether the thread waits to acquire the lock.If blocking is set to 0, the thread returns immediately with a 0 value if the lock cannot be acquired and with a 1 if the lock was acquired. If blocking is set to 1, the thread blocks and wait for the lock to be released.The release() method ... Read More

11K+ Views
The newer threading module included with Python 2.4 provides much more powerful, high-level support for threads than the thread module discussed in the previous section.The threading module exposes all the methods of the thread module and provides some additional methods −threading.activeCount() − Returns the number of thread objects that are active.threading.currentThread() − Returns the number of thread objects in the caller's thread control.threading.enumerate() − Returns a list of all thread objects that are currently active.In addition to the methods, the threading module has the Thread class that implements threading. The methods provided by the Thread class are as follows −run() − The run() method is the entry point ... Read More

488 Views
To spawn another thread, you need to call following method available in thread module −thread.start_new_thread ( function, args[, kwargs] )This method call enables a fast and efficient way to create new threads in both Linux and Windows.The method call returns immediately and the child thread starts and calls function with the passed list of args. When function returns, the thread terminates.Here, args is a tuple of arguments; use an empty tuple to call function without passing any arguments. kwargs is an optional dictionary of keyword arguments.Example#!/usr/bin/python import thread import time # Define a function for the thread def print_time( threadName, delay): count = 0 ... Read More

705 Views
To send an e-mail with mixed content requires to set Content-type header to multipart/mixed. Then, text and attachment sections can be specified within boundaries.A boundary is started with two hyphens followed by a unique number, which cannot appear in the message part of the e-mail. A final boundary denoting the e-mail's final section must also end with two hyphens.Attached files should be encoded with the pack("m") function to have base64 encoding before transmission.ExampleFollowing is the example, which sends a file /tmp/test.txt as an attachment. Try it once −#!/usr/bin/python import smtplib import base64 filename = "/tmp/test.txt" # Read a file and ... Read More

756 Views
When you send a text message using Python, then all the content are treated as simple text. Even if you include HTML tags in a text message, it is displayed as simple text and HTML tags will not be formatted according to HTML syntax. But Python provides option to send an HTML message as actual HTML message.While sending an e-mail message, you can specify a Mime version, content type and character set to send an HTML e-mail.ExampleFollowing is the example to send HTML content as an e-mail. Try it once −#!/usr/bin/python import smtplib message = """From: From Person To: ... Read More

4K+ Views
There are many sources of errors. A few examples are a syntax error in an executed SQL statement, a connection failure, or calling the fetch method for an already canceled or finished statement handle.The DB API defines a number of errors that must exist in each database module. The following table lists these exceptions.Sr.No.Exception & Description1WarningUsed for non-fatal issues. Must subclass StandardError.2ErrorBase class for errors. Must subclass StandardError.3InterfaceErrorUsed for errors in the database module, not the database itself. Must subclass Error.4DatabaseErrorUsed for errors in the database. Must subclass Error.5DataErrorSubclass of DatabaseError that refers to errors in the data.6OperationalErrorSubclass of DatabaseError ... Read More