LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   executing a python code (https://www.linuxquestions.org/questions/linux-newbie-8/executing-a-python-code-4175467486/)

sryzdn 06-26-2013 12:22 PM

executing a python code
 
Hi,

I have installed a code which has been written by python. There in the tutorial, they have said to create a personal .pythonrc file:

Quote:

import rlcompleter
import readline
readline.parse_and_bind("tab: complete")
from ase import *
I am baffled since I know nothing about python. What does this mean?

jdkaye 06-26-2013 12:32 PM

This may help you and it's free! :)
http://femhub.com/textbook-python/
jdk

slipstreamed 06-26-2013 01:25 PM

A .pythonrc file is executed when the Python interactive shell is started, if
$PYTHONSTARTUP is in your environment and points to this file. In order for the Python shell to run your pythonrc.py file on startup you need to set the PYTHONSTARTUP environment variable. Place the following line in one of your shell startup files:

Code:

export PYTHONSTARTUP=$HOME/.pythonrc.py
Code:

import rlcompleter
import readline

---> The rlcompleter module defines a completion function suitable for the readline module by completing valid Python identifiers and keywords, rlcompleter adds tab-completion for Python symbols to the interactive interpreter. Importing the module causes it to configure a completer function for readline. The only other step required is to configure the tab key to trigger the completer. Simply put this module provides word completion for python keywords, identifiers using the tab key.
The statement
Code:

readline.parse_and_bind("tab: complete")
binds the tab key on your keyboard so you can hit tab for auto-completion of python keywords, identifiers, a standard feature found in almost all IDEs.


All times are GMT -5. The time now is 09:10 AM.