Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53957

global variable across modules

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chandan_psr@yahoo.co.in>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.130
X-Spam-Level *
X-Spam-Evidence '*H*': 0.74; '*S*': 0.00; 'pointers': 0.09; 'subject:modules': 0.09; 'def': 0.12; 'subject:variable': 0.16; 'value"': 0.16; 'ignore': 0.16; 'code.': 0.18; 'variable': 0.18; 'trying': 0.19; 'import': 0.22; 'print': 0.22; 'tried': 0.27; 'point': 0.28; "i'm": 0.30; 'getting': 0.31; 'indentation': 0.31; 'file': 0.32; 'class': 0.32; 'doing': 0.36; 'method': 0.36; 'expected': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'different': 0.65; 'yes': 0.68; 'from:addr:yahoo.co.in': 0.68; 'received:106': 0.68; 'received:106.10': 0.68; 'received:106.10.166': 0.68; 'received:bullet.mail.sg3.yahoo.com': 0.68; 'received:mail.sg3.yahoo.com': 0.68; 'received:sg3.yahoo.com': 0.68; 'received:106.10.151': 0.84; 'received:106.10.166.60': 0.84
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 777403.72016.bm@omp1012.mail.sg3.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1378903830; bh=SbbZs379WsSM7YI6Ro+0j3OiNs8XDUyILQXamLE1OPQ=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=zZrJCMTyi9WOu+nQ/KGj+mu//DeNtpYshQM6Bfv3v5NKycyXbkg3OlncN5P0mUX83/Cbh8rxfkiJ24Qmm4fJYMVkIUtt5ro1YI+ZW4UkTN3xFCRn7HiRohahjpuhAglld+5hfB32CmfJdhGEO2YkaD76YehSNO0bGkvG9AnKoP4=
DomainKey-Signature a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Auju6pMc+23WLCeFT1qTCrNY3EHP/dMXYJRXoEPz38ZJ/omlS6skE5ubhS4a5orlDTHtv5XsEbk5vK1QK/q3sTBaQgmSCHMOU4Au+9TuFXDOkmuM/abUPvrgIUbTOgCPoBo7xml4DqSM9QLJFkUakQfgh8S6yDTOrHe/SMDdL/E=;
X-YMail-OSG 9tOLeBQVM1nJJSWVGtSlzaivQqFfBhNtp_7J0xixivIlsjc _iyYn3timf.usJ3y6O_lczk5U38nnKLIJX1111ZZNIYttwat1nf9NIZVMvNw .RQq2ShP1eOkVq.57KiNRLwjppQt.WxvRfzueV.RsMYb8XXLUbb6bkc6cptG 6X_1lueSh.kxN5ZVLkWBpF1qI2tbT7WUKnEX3FIhnAhgOyheY0KbLSeiRhjn a.fMI9PMgjTy4tqpj1GnW50XOeNqZEc9V91kvW4wLMfsgwQqmKH1vezqPupO .R6bjcUR.OrwEEdZmsnE9Pb2sb6_UaVh.9DZ3SPRy.cawTFd6zWeBX5OiDAp cKcgDhjymUq8idiIMvtHiNjGhdJnot6k6_0.YrNnk78Pkz7TsZGXnnCWbPav bO1zNLdyQ3q5zsMuYqxOhpanHqLbUBvg8YA4srfKnpV_gLL9spTbw4.lpbog _BT3oH8BJZelJQ4M9ZBKXutrim90SlwK_UZ.KQYkwkcX5EqfVNSqXRCYhD2q OwYsx79JRv0oR6tWTyf4Skpu5YwDBzOa7_8rgxsmD4ilyRVTpMY_vXt0cwPv E8aMcVKOOqKOE_GlkdvZxH.meN76AitSRnXhcaw9O6EVMLI1eG7WRBsR6KPb 4UacoWl0cZ28-
X-Rocket-MIMEInfo 002.001, SGkgLA0KDQpJJ20gdHJ5aW5nIHRvIHVuZGVyc3RhbmQgdXNpbmcgZ2xvYmFsIHZhcmlhYmxlIGFjcm9zcyBkaWZmZXJlbnQgbW9kdWxlcy5IZXJlIGlzIHdoYXQgaSBoYXZlIHRyaWVkIHNvIGZhciB3aXRob3V0IG11Y2ggc3VjY2Vzcy5QbGVhc2UgaWdub3JlIGFueSBpbmRlbnRhdGlvbiBpc3N1ZcKgIGluIHRoZSBiZWxvdyBjb2RlLg0KDQpGaWxlbmFtZTpUZXN0MS5weQ0KDQpEZWJ1Z19WYWx1ZSA9ICIgIg0KDQppbXBvcnQgVGVzdDINCg0KZGVmIGdsb2JhbFZhbG1ldGhvZCgpOg0KwqAgwqAgZ2xvYmFsIEQBMAEBAQE-
X-Mailer YahooMailClassic/326 YahooMailWebService/0.8.156.576
Date Wed, 11 Sep 2013 20:50:30 +0800 (SGT)
From chandan kumar <chandan_psr@yahoo.co.in>
Subject global variable across modules
To python-list@python.org
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.247.1378903988.5461.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378903988 news.xs4all.nl 15980 [2001:888:2000:d::a6]:38245
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53957

Show key headers only | View raw


Hi ,

I'm trying to understand using global variable across different modules.Here is what i have tried so far without much success.Please ignore any indentation issue  in the below code.

Filename:Test1.py

Debug_Value = " "

import Test2

def globalValmethod():
    global Debug_Value 
    Debug_Value =10
    Test2.globalValTest()

globalValmethod() -----Execute the method

Filename:Test2.py

import Test1
from Test1 import *

def globalValTest()
    print "Golabal Value" Debug_Value 
    
In Test2.py file I wanted to print the global value ,Debug_Value as 10.I'm not getting expected result.Please can any one point where exactly i'm doing wrong.

Similarly , how can i use global variable  inside a class and use the same value of global variable in different class?Is that possible?if Yes please give me some pointers on implementing. 

Best Regards,
Chandan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

global variable across modules chandan kumar <chandan_psr@yahoo.co.in> - 2013-09-11 20:50 +0800

csiph-web