C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Creating properties in Ironpython


Posted Date: 29 May 2007    Resource Type: Articles    Category: General

Posted By: Sunil Pottumuttu       Member Level: Silver
Rating:     Points: 10



The resource has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this resource.
This resource will be reviewed shortly.
If you think this resource contain inappropriate content, please report to webmaster.


Creating propeties in ironpython is some what different from c#. we can use property function to achieve this . below code demonstrates this


CODE]
class testclass1(object):
def __init__(self):
self.__x = None
self.__y = "y"

def getx(self):
return self._x

def setx(self, value):
self._x = value

def delx(self):
del self._x

x = property(getx, setx, delx, "I'm the 'x' property.")

def gety(self):
return self.__y
#read only property
y = property(gety,None,None, "I'm the 'y' property.")


obj = testclass1()
obj.x = "x";
print obj.x
print obj.y


class Parrot(object):
def __init__(self):
self._voltage = 100000

#Another way of defining ready only property using decorators
@property
def voltage(self):
"""Get the current voltage."""
return self._voltage


objparrot = Parrot()

#this gives error as it is read only property
#objparrot.voltage = "20000"
print objparrot.voltage





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: MOSS 2007 Site templates and there features
Previous Resource: Visual Studio 2008 and Visual Basic 6.0 - a Comparison
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use