473,396 Members | 1,706 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,396 software developers and data experts.

Property Descriptor - Public Getter, Private Setter

Hi all,

I was looking around the net to figure out how I can use the
property() descriptor to make a property readable by everyone and only
settable by the class or any derived classes. Thanks.

Regards,
gh

Jul 18 '07 #1
1 2213
gamehack wrote:
Hi all,

I was looking around the net to figure out how I can use the
property() descriptor to make a property readable by everyone and only
settable by the class or any derived classes. Thanks.
Forget it. You can try and come up with an implementation that will check
the stack-frames and try and see if the callers belong to the current
class, or some subclass.

But then if somebody wants to accomplish the setting by all means, he/she
just adds a new setter method to your class, and that's it.

What's your usecase? If you give us that, there might be better suggestions.

Diez
Jul 18 '07 #2

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

Similar topics

3
by: kepes.krisztian | last post by:
Hi ! I want to create a property that can use parameter(s). In Delphi I can create same thing (exm: Canvas.Pixel -> Canvas.GetPixel(self,X,Y):integer; Canvas.SetPixel(self,X,Y,Color::integer); ...
16
by: Flare | last post by:
Hi...Why can´t I access a property thorug property? Eg. class Foo { public SizeF MySize { get { return ms; } set { ms = value; } }}
4
by: Jimbo | last post by:
I am sort of new to C#. Currently have a private property called "_name" in a class. I have written a public getter and setter routine for it called "Name". Currently, the getter for the...
13
by: Peter Kirk | last post by:
Hi there, can someone tell me what exactly a "property" is in a C# class? As far as I can see it is "two methods" - ie a getter and a setter for an instance variable. What is the difference...
1
by: Steve | last post by:
I generate C# webservices proxy code from WSDL file, it turns out the classes generated have public member variables and no getter/setter methods as follows, and I am able to get data when...
6
by: Peter Franks | last post by:
Is it possible to deserialize a class that has a public property w/ a setter, but no getter? I'm not finding anything that would allow this -- Presuming that is is NOT possible, what are the...
8
by: Ethan Kennerly | last post by:
Hello, There are a lot of Python mailing lists. I hope this is an appropriate one for a question on properties. I am relatively inexperienced user of Python. I came to it to prototype...
6
by: GiJeet | last post by:
hello, I'm trying to use a dictionary as a class member. I want to use a property to get/set the key/value of the dictionary but I'm confused as how to use a dictionary as a property. Since there...
0
by: Gabriel Genellina | last post by:
En Mon, 25 Aug 2008 22:45:36 -0300, Daniel <millerdev@gmail.comescribió: (Some days late, sorry...) I like the variant below, based on your code. It avoids issue (2) by using locals(). Works...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.