
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
1K+ Views
To check if you can import something in Python 2, you can use imp module with try...except. For example, import imp try: imp.find_module('eggs') found = True except ImportError: found = False print foundThis will give you the output:FalseYou can also use iter_modules from the ... Read More

Rajendra Dharmkar
2K+ Views
You can use pip to install packages at runtime and importlib.import_module(moduleName) to import module by using its name as a string. For example, import pip import importlib def import_with_auto_install(package): try: return importlib.import_module(package) except ImportError: pip.main(['install', package]) ... Read More

Rajendra Dharmkar
257 Views
In Python, a namespace package allows you to spread Python code among several projects. This is useful when you want to release related libraries as separate downloads. For example, with the directories Package-1 and Package-2 in PYTHONPATH, Package-1/namespace/__init__.py Package-1/namespace/module1/__init__.py Package-2/namespace/__init__.py Package-2/namespace/module2/__init__.py the end-user can import namespace.module1 and import namespace.module2.On Python ... Read More

Rajendra Dharmkar
4K+ Views
If you have your own Python modules you want to copy, you can simply copy them and run on other systems with Python installed. If you want to copy installed modules, the best way is to install the same version of Python on the second system. Then run$ pip freeze ... Read More

Rajendra Dharmkar
2K+ Views
The best and recommended way to install Python modules is to use pip, the Python package manager. It automatically installs dependencies of the module as well.If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setup tools, but will need to ... Read More

Rajendra Dharmkar
588 Views
Yes you can keep Python modules in compiled format. Python automatically compiles Python source code when you import a module, so the easiest way to create a PYC file is to import it. If you have a module mymodule.py, just do:>>> import mymoduleto create a mymodule.pyc file in the same ... Read More

Rajendra Dharmkar
2K+ Views
This is not possible with the pip. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change. Even if you manage to put the code on Python path, when importing a module, python searches the paths ... Read More

Rajendra Dharmkar
581 Views
To make IntelliJ to recognize common Python modules, just create and add Python SDKFile -> Project Structure -> Project -> Project SDK -> newand select the installation path of your Python interpreter (for example, C:\Python26 in windows and /usr/bin/python2.7 in Linux) as the home path. This allows IntelliJ to look ... Read More

Rajendra Dharmkar
428 Views
You need to have Python, pip, virtualenv, awswebcli and a SSH client installed to set up your Python Development Environment on AWS. You can follow instructions at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html to install these.Once you have all those installed, you need to set up a virtual environment so that your global packages do ... Read More

Rajendra Dharmkar
195 Views
Here is a sample project that shows a very good way to structure your projects: https://github.com/kennethreitz/samplemod The project is about creating the "sample" module. The directory structure looks as follows:README.rst LICENSE setup.py requirements.txt sample/__init__.py sample/core.py sample/helpers.py docs/conf.py docs/index.rst tests/test_basic.py tests/test_advanced.pyThe README.rst file: This file is for giving a brief description ... Read More