472,952 Members | 2,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

Accessing a variable

9
I am a beginner using python2.5.1.
In my project, I have a views.py in uscom.users which has
uid=2
def disp_list():
return uid

In another module forms.py , also in uscom.users, I am trying to access that value.
from uscom.users.views import *
def id_val():
key_id = views.disp_list()
return key_id

This doesn't work. Returns error that views is not defined. Am I doing something wrong? Please help.
Sep 12 '07 #1
4 1122
ilikepython
844 Expert 512MB
I am a beginner using python2.5.1.
In my project, I have a views.py in uscom.users which has
uid=2
def disp_list():
return uid

In another module forms.py , also in uscom.users, I am trying to access that value.
from uscom.users.views import *
def id_val():
key_id = views.disp_list()
return key_id

This doesn't work. Returns error that views is not defined. Am I doing something wrong? Please help.
Yes, since you import everything (*), you don't need to acces it with the module name:
Expand|Select|Wrap|Line Numbers
  1.     key_id = disp_list()
  2.  
If you want to use "views.disp_list()":
Expand|Select|Wrap|Line Numbers
  1. import uscom.user.views as views
  2.  
If you don't have the as part you will have to use this:
Expand|Select|Wrap|Line Numbers
  1. key_id = uscom.users.views.disp_list()
  2.  
Sep 12 '07 #2
anitn
9
Hi..
thanks for the reply. Am i posting in the wrong forum? If yes please forgive. I am learning django and these methods I did try. All return errors.
Exception Value: cannot import name views
thank you once again
Sep 12 '07 #3
ilikepython
844 Expert 512MB
Hi..
thanks for the reply. Am i posting in the wrong forum? If yes please forgive. I am learning django and these methods I did try. All return errors.
Exception Value: cannot import name views
thank you once again
Try just:
Expand|Select|Wrap|Line Numbers
  1. import views
  2.  
I think since the file is in uscom.user you don't need to specify that.

Btw, you are not posting in the wrong forum.
Sep 13 '07 #4
anitn
9
Thank you alot for the reply. yes Its working now...
Sep 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
2
by: Jurek Dabrowski | last post by:
hi all, I have a question in reference to accessing variables in another class maybe someone has dealt with before. I have some public variables declared in my main plug-in class...
6
by: psbasha | last post by:
The following example shows the storing of the data and accessing the data from dictionary variable.The accessing of dictionary variable data is not a orderas what we are storing. Is my...
16
by: s0suk3 | last post by:
This code #include <stdio.h> int main(void) { int hello = {'h', 'e', 'l', 'l', 'o'}; char *p = (void *) hello; for (size_t i = 0; i < sizeof(hello); ++i) {
0
by: ss3944 | last post by:
I need to pass a variable as a parameter from shell script into a DB2 database. Code: var=bhuk_1123_Q_11/22/09 select * from tbl1 where serial_id='$var';
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.