You Are Here:

Community: Developer Discussion Boards

#1 Old Cool Help:How to share variable between two modules - 2008-12-12, 03:08

Join Date: Oct 2008
Posts: 6
yotiger
Offline
Registered User
[config.py]
DeviceName = u"PY_Test"

[main.py]
from config import *
global DeviceName
print(u"DeviceName :" + DeviceName)

When run main.py on my phone(E65), it throws out an error that DeviceName is not defined. But it works well on PC.
Reply With Quote

#2 Old Re: Help:How to share variable between two modules - 2008-12-12, 04:36

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by yotiger View Post
[config.py]
DeviceName = u"PY_Test"

[main.py]
from config import *
global DeviceName
print(u"DeviceName :" + DeviceName)

When run main.py on my phone(E65), it throws out an error that DeviceName is not defined. But it works well on PC.
hello yogiter
please have a look at this article it cn help you a bit.

Enjoy Pythoning
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#3 Old Re: Help:How to share variable between two modules - 2008-12-12, 07:16

Join Date: Oct 2008
Posts: 6
yotiger
Offline
Registered User
Hi gaba88,
Thanks for your response.
I tried all the methods in that article.They do not work.

[code]from config import a[code]
[error info]ImportError:cannot import name a
Reply With Quote

#4 Old Re: Help:How to share variable between two modules - 2008-12-12, 11:42

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by yotiger View Post
[config.py]
DeviceName = u"PY_Test"

[main.py]
from config import *
global DeviceName
print(u"DeviceName :" + DeviceName)

When run main.py on my phone(E65), it throws out an error that DeviceName is not defined. But it works well on PC.
Try without declaring DeviceName as global.
Reply With Quote

#5 Old Re: Help:How to share variable between two modules - 2008-12-12, 15:12

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
Quote:
Originally Posted by yotiger View Post
Hi gaba88,
Thanks for your response.
I tried all the methods in that article.They do not work.

[code]from config import a[code]
[error info]ImportError:cannot import name a
Hi yotiger,


Try to use this code:

Code:
import sys

sys.path.append('E:\\Python')

import extension

variable = extension.a

print variable

BR,

Rafael.
Reply With Quote

#6 Old Re: Help:How to share variable between two modules - 2008-12-17, 09:21

Join Date: Oct 2008
Posts: 6
yotiger
Offline
Registered User
Hi,

I still can not import a variable from another module.
Reply With Quote

#7 Old Re: Help:How to share variable between two modules - 2008-12-17, 09:22

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by croozeus View Post
Try without declaring DeviceName as global.
Have you tried what I suggested earlier. It worked for me.
Reply With Quote

#8 Old Re: Help:How to share variable between two modules - 2008-12-17, 09:31

Join Date: Oct 2008
Posts: 6
yotiger
Offline
Registered User
Quote:
Originally Posted by croozeus View Post
Have you tried what I suggested earlier. It worked for me.
I have tried so. But it does not work. It says 'str' is not defined. Strangely, it does work on my desktop.

[config.py]
str = "123"

[main.py]
import sys

sys.path.append('E:\\Python')

from config import *

print str.
Reply With Quote

#9 Old Re: Help:How to share variable between two modules - 2008-12-17, 10:02

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by yotiger View Post
I have tried so. But it does not work. It says 'str' is not defined. Strangely, it does work on my desktop.

[config.py]
str = "123"

[main.py]
import sys

sys.path.append('E:\\Python')

from config import *

print str.
Code:
[config.py]
DeviceName = u"PY_Test"

[main.py]
import sys
sys.path.append('E:\\Python')
import config
print DeviceName
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
share variable with images issue momocha Mobile Java General 3 2008-11-07 15:28
Strange Compilation error: fatal error: error writing to -: Invalid argument Evgeniz General Symbian C++ 4 2007-05-31 08:06
load multiple images using 1 CFbsBitmap variable result in same image Rx-lee General Symbian C++ 1 2006-11-15 08:03
Conditional compilation: managing set of modules doctordwarf General Symbian C++ 3 2004-08-31 15:01
Modules stenlik Symbian Networking & Messaging 1 2004-06-09 10:30

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia