Environments in python, Python Programming

Environments in Python

Generally, Python establishes the following binding environments:

1.  builtin    : the mother of all environments: it contains the de?nitions of all sorts of basic function, like sum and list. It is the parent of all module environments.

2.  Module: each  separate ?le that  contains Python code  is called  a module and  establishes its own environment, whose  parent is      builtin

3.  Procedure calls: A Function that is described at the 'top level' of a module (that is, not nested in the de?nition of another procedure) has the module's  environment  as its parent, and  has its name  described in the module's environment.  Methods that are described under  other  procedures have  the  procedure-call environment of the  containing procedure as their parent.

We have seen two operations that cause bindings to be created:  assignments and procedure calls. Bindings  are also created when  you compute an import statement. If you compute import math then  a ?le associated with  the  math module is computed and  the  name  math is related, in the current environment, to the math  module, which  is an environment. No other values  are included to the current environment, and if you need  to show to names  in that part, you have to examine them, as in math.sqrt. If you run from math import sqrt then  the  math ?le is computed, and  the  name  sqrt is related, in the  current environment, to whatever the name  sqrt is bound in the math function. But note  that  if you  do this,  the name math is not related to anything, and  you cannot take any other  procedures in the math module unless  you import them  outside,  as well

 

Posted Date: 8/11/2012 2:44:35 AM | Location : United States







Related Discussions:- Environments in python, Assignment Help, Ask Question on Environments in python, Get Answer, Expert's Help, Environments in python Discussions

Write discussion on Environments in python
Your posts are moderated
Related Questions
Task This problem creates a list containing names. The list of names will be printed, sorted, printed again in the new sorted order, written to a new output file, and searched. Ca

I need how to write small kind of viruses...

Finally! After years of adding unimportant sports, the IOC has finally added Shoe Tying to the Olympics. And you’ve been selected to write the software to handle the judging of t

draw the variation of pressure with volume of a real gas at temperatures lower than its critical temperature.also draw its surface of discontinuity

Write an algorithm for the sum of the given series 1,-1/2,1/4,-1/8.....

how to make a python programme for van der waals equation of state with surface discontinouty

#ques Write the pseudocode (use a word processor please) and the Python 3.0 program for the following problem. A monkey is being fed some food. Read in the starting weight in lbs:o

Write an algorithm for a program that shows the use of all 6 math functions. Write, test, and debug the program using Python. SAMPLE OUTPUT (not including author/program infor

Write a program that will take price data for stocks and print it graphically to the screen. Your program should begin by asking the user for the file name. It should then create a

Procedure calls When you compute an expression of the form ( ,  ..., )   the Python interpreter treats  this as a procedure call. It will be simpler to talk about