473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

properties with subscripted variables

Hi,
I work on the python module AVC (http://avc.inrim.it) useful for the
development of applications with GUIs. AVC is based on the property
mechanism: any a variable controlled by AVC is set as a property, so
when it is assigned by the application program, the __set__ function
is called and AVC does its job. This works fine with non sequence
types and with sequence types when are assigned as a whole, without
subscripting. When the assignment has a subscript, the __set__ method
is no more called. This is a limitation from the point of view of AVC.
My goal would be to be able to intercept (trigger a call to a method
of my module) any kind of variable assignment, even if it is a
sequence type with a subscript.
There is a way to reach this result with properties or with other
ways?

Best regards,
F. Pollastri
Aug 26 '08 #1
1 1418
Fabrizio Pollastri a écrit :
Hi,
I work on the python module AVC (http://avc.inrim.it) useful for the
development of applications with GUIs. AVC is based on the property
mechanism: any a variable controlled by AVC is set as a property, so
when it is assigned by the application program, the __set__ function
is called and AVC does its job. This works fine with non sequence
types and with sequence types when are assigned as a whole, without
subscripting. When the assignment has a subscript, the __set__ method
is no more called.
Nope, but the __get__ method is.
This is a limitation from the point of view of AVC.
My goal would be to be able to intercept (trigger a call to a method
of my module) any kind of variable assignment, even if it is a
sequence type with a subscript.
There is a way to reach this result with properties or with other
ways?
The code:

obj.prop[x] = y

is equivalent to:

prop = obj.prop
prop[x] = y

IOW, you just have to return from prop.__get__ a custom sequence type
implementing __setitem__ the way you see fit.

Also, remember that properties are just one possible way to use the
descriptor protocol to implement computed attributes. You can define
your own descriptor objects.

HTH
Aug 26 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: julien | last post by:
Hello, I don't know when to use fields and when to used properties. It looks to me that using properties is always better. But I guess fields must be better in some cases, otherwise they wouldn't...
4
by: Mantorok | last post by:
Hi I have an ASP app which references a few static properties in some of the classes. I understand that you should use Session variables, but is it "possible" to have each session "not"...
8
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that...
11
by: Brent Ritchie | last post by:
Hello all, I have been using C# in my programming class and I have grown quite fond of C# properties. Having a method act like a variable that I can control access to is really something. As...
10
by: Zhou Yan | last post by:
I want to define a pointer to a multiple-subscripted array. For instance, I have an array defined as below( I have reduced the size of the array as well as the dimension, but I think it OK to ask...
1
by: andyIOM | last post by:
okay, i have tried,googled and read but havn't managed to figure out where the error is. bascically,my file reads an in put file which looks like this: Is 2 1 50 R1 2 9 500 R2 1 0 100 R3 2...
26
by: optimistx | last post by:
A variable in global scope var a1 = 'contents of global variable a1'; can be references (with some limitations) as window; // or window.a1; // or even window;
8
by: Harry8888 | last post by:
Hello all, I'am stuck on the following error: test.c:9: error: subscripted value is neither array nor pointer I think I am doing something wrong with the variable rot, but I can't quite figure...
3
by: Duggi | last post by:
As I read, one of the advantage of implementing auto-Implemented Properties is to avoid the accidental access/ modification of the private variable in the class. However If set or get needs to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.