
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
Rajendra Dharmkar has Published 189 Articles

Rajendra Dharmkar
5K+ Views
To create a file of a particular size, just seek to the byte number(size) you want to create the file of and write a byte there.For examplewith open('my_file', 'wb') as f: f.seek(1024 * 1024 * 1024) # One GB f.write('0')This creates a sparse file by not ... Read More

Rajendra Dharmkar
317 Views
If you are modifying a module and want to test it in the interpreter without having to restart the shell everytime you save that module, you can use the reload(moduleName) function. reload(moduleName) reloads a previously loaded module (assuming you loaded it with the syntax "import moduleName". It is intended for ... Read More

Rajendra Dharmkar
1K+ Views
You can use the os.chroot to change the root directory of the current process to path. This command is only available on Unix systems. You can use it as follows:>>> import os >>> os.chroot('/tmp/my_folder')This changes the root directory of the script running to /tmp/my_folder.Read More

Rajendra Dharmkar
306 Views
To get stat of a file, method stat() from the os module can be used. It performs a stat system call on the given path. For example, import os st = os.stat("file.dat")This function takes the name of a file, and returns a 10-member tuple with the following contents:(mode, ino, dev, ... Read More

Rajendra Dharmkar
2K+ Views
Currently you cannot add namespaces to XML documents directly as it is not yet supported in the in built Python xml package. So you will need to add namespace as a normal attribute to the tag. For example, import xml.dom.minidom doc = xml.dom.minidom.Document() element = doc.createElementNS('http://hello.world/ns', 'ex:el') element.setAttribute("xmlns:ex", "http://hello.world/ns") doc.appendChild(element) ... Read More

Rajendra Dharmkar
805 Views
The basic way to do output to screen is to use the print statement.>>> print 'Hello, world' Hello, worldTo print multiple things on the same line separated by spaces, use commas between them. For example:>>> print 'Hello, ', 'World' Hello, WorldWhile neither string contained a space, a space was added ... Read More

Rajendra Dharmkar
1K+ Views
Globals in Python are global to a module, not across all modules. (Unlike C, where a global is the same across all implementation files unless you explicitly make it static.). If you need truly global variables from imported modules, you can set those at an attribute of the module where ... Read More