Python/IronPython- how to return value of specific attribute of class when only class object referenced? -


ok, trying python, specifically, i'm using benefit of on-the-fly calculations within c# app calling ironpython engine. pass in ip list of c# objects of class c, , going bunch of calculations. there's legacy (sql) reference member of class, call currentamount. there other values of attributes referenced in calculations wondering if there's way automatically return value of currentamount if object referenced.

c# class mynumbersclass

public class mynumbersclass {    decimal someval_a;    decimal someval_b;    decimal currentamount; } 

... gather list called numberslist...

... instantiate ironpython engine e ... set scope s ... set ip list pnumbers c# list numberslist

s.setvariable(pnumbers, numberslist) 

so now, simple calculation in ironpython(ip) calculate following:

pnumbers[10].currentamount = pnumbers[0].someval_a * (pnumbers[2].someval_b / daysinweek) - pnumbers[5].currentamount 

how can re-write currentamount default attribute set , when none specified? i.e., pnumbers[10] = pnumbers[0].someval_a * (pnumbers[2].someval_b / daysinweek) - pnumbers[5]

i have way over-simplified example can existing legacy attributes of passed in c# class long , wordy, , currentamount default attribute set and/or referenced , half of size of legacy name commonly used attribute.

i realize type there might unintended consequences of i'm asking - i.e., when want reference object of class whole.

any ideas?

it you're dealing lists of items, create class in c# wraps list , implements __getitem__ , __setitem__ (basically overloading [] operator) refer currentammount. you'll lose ability replace element of list python, might not matter in case.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -