Sick problem with Python properties

Discussion in 'Python' started by webmaster@t-dose.de, Aug 7, 2003.

  1. Guest

    See the following code. I wonder why in this case neither
    setp() nor getp() is called !?


    yetix@/home/ajung(1)% cat test.py
    class A:

    def __init__(self):
    self._p=None

    def setp(self, p):
    print 'set'
    self._p = p*p

    def getp(self):
    print 'get'
    return self._p

    pp = property(getp, setp)


    inst=A()
    inst.p = 9
    print inst.p

    yetix@/home/ajung(2)% python2.3 test.py
    9

    Cheers,
    -aj
    , Aug 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johnny Emde

    SO DAM SICK of this error

    Johnny Emde, Oct 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    Ken Cox [Microsoft MVP]
    Oct 15, 2005
  2. James Kimble
    Replies:
    36
    Views:
    1,101
    unbending
    Jan 26, 2005
  3. Markus Elfring
    Replies:
    2
    Views:
    366
    Markus Elfring
    Feb 23, 2005
  4. adfgvx

    Sick (yaml library) and Python

    adfgvx, Sep 20, 2003, in forum: Python
    Replies:
    0
    Views:
    305
    adfgvx
    Sep 20, 2003
  5. Robert Brewer

    derivation: sick Python trick of the week

    Robert Brewer, Feb 23, 2004, in forum: Python
    Replies:
    5
    Views:
    406
Loading...

Share This Page