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
#que 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 cre

Write a program that asks the user to enter a number of seconds. The responses of the program will vary depending on the length of seconds: • If the number of seconds is under 60

Task (Anagrams) Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters. Fore example, silent and listen are anagrams.

what is python

Procedures in python Procedures are computer program creates that let us capture common patterns of computation by: Grouping together sequences of statements

Synthetic models One  goal  of various  people in a variety of sub-disciplines of  electrical  engineering and  computer science is automatic synthesis of machine from  formal

List Comprehensions   Python has a very nice built-in  facility for doing  many  iterative methods, known as list comprehensions. The basic template is       [

I need server, client and trusted side communicating and charging a service with that protocol (or needham shroeder)

Non-local references So far, whenever we needed to compute a variable, there  was  a binding for that  variable in the 'local' environment (the environment in which  we were e

protocol rdt2.2 considers there is a bit errors between sender to receiver and also from receiver to sender. So now we have to consider checking bit errors introduced in reply from