Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'subject:not': 0.03; 'subject:Why': 0.09; 'def': 0.12; 'subject:class': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'skip:s 30': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version:': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'charset:windows-1252': 0.65; 'contact': 0.67; 'mistake': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=tBIK6YkVRoeRX6/76Vh1Rk5STD+mJRiqSNiCqlB2dHY=; b=JM0yezHovh+VM6oHtGY7vd15XYT32pgNw1GqQeU7Iue8xpR1fyoD7uucGGBtv9L6Dt jtpXsOqgiwA1iRS/8yd8HJgfIa7G2XqfM5BotcTQB2MEY3+NKhWYDpMiv9AjZwiCkhTr hfJLaCdKGXtkP4nHf3/LQVliEX6b5xSyYw7Wu0pL7oq1eQMbFuf6+QG+O7OGh601Et4s 2pPG4wuIlsxtqSXcB4X3KMywWyoZTrCsvbVUZd++sGnPiBnBi4jFffRwYdA0jZ2miG2M M1FWTLmP6cx8f56Q7IUuKuH+ME3WSsfqSUFux5DpEchkLBpkYynKyWgfKquNNbpaKWAb VAfQ== X-Received: by 10.70.103.204 with SMTP id fy12mr9961067pdb.144.1408750210719; Fri, 22 Aug 2014 16:30:10 -0700 (PDT) Date: Sat, 23 Aug 2014 07:29:44 +0800 From: luofeiyu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Steven D'Aprano , python-list@python.org Subject: Re: Why can not initialize the class? References: <53F752FA.8080902@gmail.com> <53F756BF.1030100@gmail.com> <53f75f22$0$6512$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <53f75f22$0$6512$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408750213 news.xs4all.nl 2970 [2001:888:2000:d::a6]:51204 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76832 One final version: class Contact(object): def __init__(self, email="haha@haha"): self.email = email def _get_email(self): return self._the_secret_private_email def _set_email(self, value): self.self._the_secret_private_email = value email = property(_get_email, _set_email) contact = Contact() print(contact.email) There is a little mistake here. It is self._the_secret_private_email = value not self.self._the_secret_private_email = value think for your demo .The value in `def _set_email(self, value):` is the value of self.email .