Welcome to WEAP's Website WEAP
WEAP is an initiative of the Stockholm Environment Institute.


About WEAP

Home
Why WEAP?
Features
What's New?
Sample Screens
Demonstration
Publications
History and Credits

Using WEAP
Download
Licensing
User Guide
Tutorial
Videos

User Forum
Discussions
Members List
Edit Profile

Additional Support
Training
University Courses
Collaboration

About Us
SEI-US Water Resources Program
Please Contact Us


Environmental News
LEAP
Interested in Energy?
Read about LEAP: SEI's software for energy planning.
   

User Forum

All Topics | Topic "Error in reading variable's value via Python"
Log in to post new messages or reply to existing messages.
 
Author Message
Mr. Mostafa Fard

Subject: Error in reading variable's value via Python   
Posted: 2/1/2018 Viewed: 873 times
Hi,
When I run the following code in JScript, I see the result
JScript Code:
var WEAP = new ActiveXObject("WEAP.WEAPApplication");
WEAP.ActiveArea = "Tutorial";
var V = WEAP.Branch("\\Demand Sites\\City").Variables("Annual Activity Level");
var Temp = V.Value(2011, 1, "No LEAP Link");
print("Done. Value = " + Temp);

But when I run the equivalent code in python (following code) I get an error
Python Code:
import win32com.client
WEAP = win32com.client.Dispatch('WEAP.WEAPApplication')
v = WEAP.Branch('\\Demand Sites\\demand').Variables('Monthly Variation').Value(2015, 1)
print('Done. {}'.format(v))

Error: TypeError: 'float' object is not callable

Note) If I use Value without any parameter (like a property), it works but just return the first value (for example when I use MonthlyValues for its Expression {I mean using WEAP.Branch('\\Demand Sites\\demand').Variables('Monthly Variation').Value}

What should I do to read values of a variable (for individual timesteps) in Python?!?
Topic "Error in reading variable's value via Python"