Simplified attribute accessors using overloading

Category: Python - Miscellaneous

This script presents an ideom for simplified accessors, that combines typical getter and setter functionality of an attribute into a single overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can now just be called ATTRIBUTE. When called without arguments it acts as a getter and retrieves the attribute's value. When called with arguments, the attribute is set to this value. Date: 14 February, 2012


Attribute Accessors - Overload Method - Attribute Value - Attribute - Accessors - Value

Homepage: http://code.activestate.com

Developer: code.activestate.com

License: Artistic License, GNU General Public License (GPL)

Operating System: Windows, Linux, Mac OS, BSD, Solaris

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

This script presents an ideom for simplified accessors, that combines typical getter and setter functionality of an attribute into a single overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can now just be called ATTRIBUTE.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script contains a few simple descriptor classes to compute and cache attribute value on demand and to define attribute as alias to other.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script defines a dictionary with attribute-style access.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Python has no inherent provision for a restrictive API that blocks accesses to methods and variables outside an allowed set.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script presents a way to introduce proper attribute access protection levels using a generic proxy object.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Whenever a superclass implements a __init__ method to initialize its attributes, subclasses derived from it have to invoke the __init__ method of the superclass.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script uses the 'Multicast' class to multiplex messages/attribute requests to objects which share the same interface.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Forbidding inheritance script shows how to prevent the use of a class asForbiddinlass.

developer Developer: code.activestate.com
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris


Generic cacheable value objects superclass script is a superclass for cache value objects by its constructor arguments.

developer Developer: code.activestate.com
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris