[IronPython] property bug? or my mistake?
Kevin Chu
redmoon17 at gmail.com
Mon May 7 04:51:34 CEST 2007
thanks a lot
On 5/7/07, Dino Viehland <dinov at exchange.microsoft.com> wrote:
>
> Your class needs to inherit from object for properies (and descriptors in
> general) to work:
>
> class SampleClass(object):
> "Sample class with one property"
> def __init__(self):
> self.__testString = ""
> def SetTestString(self, value):
> self.__testString = value.upper ()
> def GetTestString(self):
> return self.__testString
> TestString = property(GetTestString, SetTestString)
> ------------------------------
> *From:* users-bounces at lists.ironpython.com [
> users-bounces at lists.ironpython.com] On Behalf Of Kevin Chu [
> redmoon17 at gmail.com]
> *Sent:* Sunday, May 06, 2007 6:59 PM
> *To:* Discussion of IronPython
> *Subject:* [IronPython] property bug? or my mistake?
>
>
> I do this walkthought:
> http://quickstarts.asp.net/Futures/dlr/doc/dlsharedcode.aspx
> but when I change some code ,want to get Upper string, but my code is not
> working
> my code is:
>
> class SampleClass:
> "Sample class with one property"
> def __init__(self):
> self.__testString = ""
> def SetTestString(self, value):
> self.__testString = value.upper ()
> def GetTestString(self):
> return self.__testString
> TestString = property(GetTestString, SetTestString)
> or
>
> class SampleClass:
> "Sample class with one property"
> def __init__(self):
> self.__testString = ""
> def SetTestString(self, value):
> self.__testString = str(value).upper()
> def GetTestString(self):
> return self.__testString
> TestString = property(GetTestString, SetTestString)
>
> or
>
> class SampleClass:
> "Sample class with one property"
> def __init__(self):
> self.__testString = ""
> def SetTestString(self, value):
> self.__testString = value
> def GetTestString(self):
> return self.__testString.upper()
> TestString = property(GetTestString, SetTestString)
> --
> Once in a Redmoon
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
--
Once in a Redmoon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070507/f5562e3c/attachment.html>
More information about the Ironpython-users
mailing list