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

About WEAP

What's New?
Sample Screens
History and Credits

Using WEAP
User Guide
Videos (YouTube)

User Forum
Members List
Edit Profile

Additional Support
University Courses

About Us
SEI-US Water Resources Program
Please Contact Us

Environmental News
Not acting like themselves: Antidepressants in environment alter crayf...
Expose crayfish to antidepressants, and they become more outgoing -- but that might not be such a positive thing for the...

Heat from below: How the ocean is wearing down the Arctic sea ice
The influx of warmer water masses from the North Atlantic into the European marginal seas plays a significant role in th...

Research reveals why people pick certain campsites
Those in love with the outdoors can spend their entire lives chasing that perfect campsite. New research suggests what t...
Source: Science Daily
Interested in Energy?
Read about LEAP: SEI's software for energy planning.

Link WEAP and LEAP for combined Water-Energy planning.
Watch a video demo!

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: 4340 times
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"