Global variables in Python

How do we share global variables across modules in Python?

- We can create a config file & store the entire global variable to be shared across modules or script in it. By simply importing config, the entire global variable defined it will be available for use in other modules.
- For example I want a, b & c to share between modules.
config.py :
a=0
b=0
c=0

module1.py:
import config
config.a = 1
config.b =2
config.c=3
print “ a, b & resp. are : “ , config.a, config.b, config.c
------------------------------------------------------------------------
output of module1.py will be
1 2 3
Pass optional from one function to another in Python
Pass optional from one function to another - Gather the arguments using the * and ** specifiers in the function's parameter list. This gives us positional arguments as a tuple and the keyword arguments.......
Indexing and slicing operation in sequences
Indexing and slicing operation in sequences - Different types of sequences in python are strings, Unicode strings, lists, tuples, buffers, and xrange objects.......
What is a Lambda form?
The lambda form: Using lambda keyword tiny anonymous functions can be created.......
Post your comment