Rajendra Dharmkar has Published 452 Articles

How do I get IntelliJ to recognize common Python modules?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:55:23

425 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

How to use pip to install python modules in easy way?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:48:40

2K+ Views

If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:On Linux or macOS:pip install -U pip setuptoolsOn Windows:python -m pip install -U pip setuptoolsIf you’re using a Python install on Linux ... Read More

How to set up your python development environment on AWS?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:45:55

292 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

What is the convention for structuring Python modules?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:44:20

117 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

How to install Python modules in Cygwin?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:43:25

1K+ Views

While installing cygwin, make sure you install the python/python-setuptools from the list. This will install "easy_install" package. Once you have easy_install, you can use it to install pip. Type the following command:$ easy_install-a.b pipYou must replace a.b with your python version which can be 2.7 or 3.4 or whatever else. ... Read More

How to encapsulate Python modules in a single file?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 01-Oct-2019 06:42:13

583 Views

You cannot, in general encapsulate Python modules in a single file. Because doing so would destroy the module searching method that python uses (files and directories). If you are not able to install modules on a machine(due to not having enough permissions), you could use either virtualenv or save the ... Read More

What are the differences between json and simplejson Python modules?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Sep-2019 08:59:36

640 Views

json is simplejson, added to the stdlib. But since json was added in 2.6, simplejson has the advantage of working on more Python versions (2.4+).simplejson is also updated more frequently than Python. Although they are the same, the version included in the stdlib doesn't include the latest optimizations. So if ... Read More

What is the difference between dir(), globals() and locals() functions in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Sep-2019 08:56:48

520 Views

locals() returns you a dictionary of variables declared in the local scope while globals() returns you a dictionary of variables declared in the global scope. At global scope, both locals() and globals() return the same dictionary to global namespace. To notice the difference between the two functions, you can call ... Read More

What does reload() function do in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Sep-2019 08:55:31

1K+ Views

The function reload(moduleName) reloads a previously loaded module (assuming you loaded it with the syntax "import moduleName". It is intended for conversational use, where you have edited the source file for a module and want to test it without leaving Python and starting it again. For example, >>> import mymodule ... Read More

How can I get a list of locally installed Python modules?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Sep-2019 08:54:02

3K+ Views

There are multiple ways to get a list of locally installed Python modules. Easiest way is using the Python shell, for example, >>> help('modules') Please wait a moment while I gather a list of all available modules... BaseHTTPServer      brain_nose          markupbase         ... Read More

Advertisements